ruflet_core 0.0.9
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 +7 -0
- data/README.md +3 -0
- data/lib/ruflet/version.rb +5 -0
- data/lib/ruflet.rb +3 -0
- data/lib/ruflet_core.rb +40 -0
- data/lib/ruflet_protocol/ruflet/protocol.rb +62 -0
- data/lib/ruflet_protocol.rb +4 -0
- data/lib/ruflet_ui/ruflet/app.rb +27 -0
- data/lib/ruflet_ui/ruflet/colors.rb +234 -0
- data/lib/ruflet_ui/ruflet/control.rb +281 -0
- data/lib/ruflet_ui/ruflet/dsl.rb +291 -0
- data/lib/ruflet_ui/ruflet/event.rb +42 -0
- data/lib/ruflet_ui/ruflet/events/gesture_events.rb +552 -0
- data/lib/ruflet_ui/ruflet/icon_data.rb +62 -0
- data/lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb +54 -0
- data/lib/ruflet_ui/ruflet/icons/cupertino_icon_lookup.rb +70 -0
- data/lib/ruflet_ui/ruflet/icons/material/material_icons.rb +55 -0
- data/lib/ruflet_ui/ruflet/icons/material_icon_lookup.rb +70 -0
- data/lib/ruflet_ui/ruflet/page.rb +1222 -0
- data/lib/ruflet_ui/ruflet/types/geometry.rb +65 -0
- data/lib/ruflet_ui/ruflet/types/text_style.rb +191 -0
- data/lib/ruflet_ui/ruflet/ui/control_factory.rb +53 -0
- data/lib/ruflet_ui/ruflet/ui/control_methods.rb +17 -0
- data/lib/ruflet_ui/ruflet/ui/control_registry.rb +33 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactionsheet_control.rb +57 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactionsheetaction_control.rb +58 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactivityindicator_control.rb +57 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoalertdialog_control.rb +39 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoappbar_control.rb +44 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinobottomsheet_control.rb +38 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinobutton_control.rb +73 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocheckbox_control.rb +70 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocontextmenu_control.rb +34 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocontextmenuaction_control.rb +36 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinodatepicker_control.rb +67 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinodialogaction_control.rb +35 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinofilledbutton_control.rb +73 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinolisttile_control.rb +67 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinonavigationbar_control.rb +61 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinopicker_control.rb +66 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoradio_control.rb +66 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinosegmentedbutton_control.rb +63 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoslider_control.rb +64 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoslidingsegmentedbutton_control.rb +60 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoswitch_control.rb +73 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotextfield_control.rb +159 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotimerpicker_control.rb +61 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotintedbutton_control.rb +73 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/ruflet_controls.rb +89 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/alertdialog_control.rb +58 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/appbar_control.rb +53 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/audio_control.rb +36 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/autocomplete_control.rb +58 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/badge_control.rb +31 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/banner_control.rb +47 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/bottomappbar_control.rb +62 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/bottomsheet_control.rb +48 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/button_control.rb +69 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/card_control.rb +63 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/chart_controls.rb +321 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/checkbox_control.rb +76 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/chip_control.rb +88 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/circleavatar_control.rb +62 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/container_control.rb +81 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/contextmenu_control.rb +63 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datacell_control.rb +38 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datacolumn_control.rb +34 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datarow_control.rb +35 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datatable_control.rb +78 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/datepicker_control.rb +55 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/daterangepicker_control.rb +57 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/divider_control.rb +36 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdown_control.rb +99 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdownm2_control.rb +119 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdownoption_control.rb +35 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/expansionpanel_control.rb +61 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/expansionpanellist_control.rb +60 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/expansiontile_control.rb +82 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/filledbutton_control.rb +69 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/fillediconbutton_control.rb +81 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/filledtonalbutton_control.rb +69 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/filledtonaliconbutton_control.rb +81 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/floatingactionbutton_control.rb +73 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/iconbutton_control.rb +81 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/listtile_control.rb +87 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/menubar_control.rb +33 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/menuitembutton_control.rb +67 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationbar_control.rb +67 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationbardestination_control.rb +35 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationdrawer_control.rb +41 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationdrawerdestination_control.rb +34 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationrail_control.rb +70 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationraildestination_control.rb +36 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/option_control.rb +35 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/outlinedbutton_control.rb +66 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/outlinediconbutton_control.rb +81 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/popupmenubutton_control.rb +74 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/popupmenuitem_control.rb +38 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/progressbar_control.rb +64 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/progressring_control.rb +65 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/radio_control.rb +70 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/radiogroup_control.rb +33 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/rangeslider_control.rb +67 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/reorderablelistview_control.rb +80 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/ruflet_controls.rb +252 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/searchbar_control.rb +94 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/segment_control.rb +33 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/segmentedbutton_control.rb +63 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/selectionarea_control.rb +32 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/slider_control.rb +76 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/snackbar_control.rb +51 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/submenubutton_control.rb +66 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/switch_control.rb +77 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tab_control.rb +35 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tabbar_control.rb +77 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tabbarview_control.rb +57 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/tabs_control.rb +59 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/textbutton_control.rb +66 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/textfield_control.rb +148 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/timepicker_control.rb +50 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/verticaldivider_control.rb +36 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/video_control.rb +39 -0
- data/lib/ruflet_ui/ruflet/ui/controls/materials/webview_control.rb +35 -0
- data/lib/ruflet_ui/ruflet/ui/controls/ruflet_controls.rb +447 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/animatedswitcher_control.rb +59 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/arc_control.rb +29 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/autofillgroup_control.rb +32 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/basepage_control.rb +44 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/browsercontextmenu_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/canvas_control.rb +57 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/circle_control.rb +25 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/color_control.rb +23 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/column_control.rb +67 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/dialogs_control.rb +22 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/dismissible_control.rb +66 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/draggable_control.rb +39 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/dragtarget_control.rb +36 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/fill_control.rb +22 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/fletapp_control.rb +62 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/gesturedetector_control.rb +129 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/gridview_control.rb +71 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/hero_control.rb +56 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/icon_control.rb +64 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/image_control.rb +27 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb +69 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/keyboardlistener_control.rb +36 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/line_control.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/listview_control.rb +71 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/markdown_control.rb +70 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/mergesemantics_control.rb +31 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/oval_control.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/overlay_control.rb +22 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/page_control.rb +74 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/pagelet_control.rb +64 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/pageview_control.rb +64 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/path_control.rb +23 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/placeholder_control.rb +58 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/points_control.rb +24 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/rect_control.rb +27 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/reorderabledraghandle_control.rb +56 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/responsiverow_control.rb +61 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/row_control.rb +67 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/ruflet_controls.rb +140 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/safearea_control.rb +61 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/semantics_control.rb +79 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/serviceregistry_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/shadermask_control.rb +57 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/shadow_control.rb +25 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/shimmer_control.rb +60 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/stack_control.rb +58 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/text_control.rb +32 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/textspan_control.rb +39 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/transparentpointer_control.rb +54 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/view_control.rb +77 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/window_control.rb +56 -0
- data/lib/ruflet_ui/ruflet/ui/controls/shared/windowdragarea_control.rb +58 -0
- data/lib/ruflet_ui/ruflet/ui/cupertino_control_factory.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/cupertino_control_methods.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/cupertino_control_registry.rb +49 -0
- data/lib/ruflet_ui/ruflet/ui/material_control_factory.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/material_control_methods.rb +170 -0
- data/lib/ruflet_ui/ruflet/ui/material_control_registry.rb +168 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/accelerometer_control.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/barometer_control.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/battery_control.rb +22 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/camera_control.rb +58 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/clipboard_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/connectivity_control.rb +22 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/filepicker_control.rb +23 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/flashlight_control.rb +22 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/gyroscope_control.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/hapticfeedback_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/magnetometer_control.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/screenbrightness_control.rb +23 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/screenshot_control.rb +31 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/semanticsservice_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/shakedetector_control.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/share_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/sharedpreferences_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/storagepaths_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/urllauncher_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/useraccelerometer_control.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet/wakelock_control.rb +21 -0
- data/lib/ruflet_ui/ruflet/ui/services/ruflet_services.rb +66 -0
- data/lib/ruflet_ui/ruflet/ui/shared_control_forwarders.rb +129 -0
- data/lib/ruflet_ui/ruflet/ui/widget_builder.rb +64 -0
- data/lib/ruflet_ui.rb +160 -0
- metadata +245 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "ui/control_methods"
|
|
4
|
+
require_relative "ui/control_factory"
|
|
5
|
+
|
|
6
|
+
module Ruflet
|
|
7
|
+
module DSL
|
|
8
|
+
DURATION_FACTORS_MS = {
|
|
9
|
+
days: 86_400_000.0,
|
|
10
|
+
hours: 3_600_000.0,
|
|
11
|
+
minutes: 60_000.0,
|
|
12
|
+
seconds: 1_000.0,
|
|
13
|
+
milliseconds: 1.0,
|
|
14
|
+
microseconds: 0.001
|
|
15
|
+
}.freeze
|
|
16
|
+
|
|
17
|
+
module_function
|
|
18
|
+
|
|
19
|
+
def default_host
|
|
20
|
+
ENV["RUFLET_HOST"].to_s.strip.empty? ? "0.0.0.0" : ENV["RUFLET_HOST"].to_s
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def default_port
|
|
24
|
+
raw = ENV["RUFLET_PORT"].to_s
|
|
25
|
+
value = raw.to_i
|
|
26
|
+
value > 0 ? value : 8550
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def _pending_app
|
|
30
|
+
@_pending_app ||= App.new(host: default_host, port: default_port)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def _reset_pending_app!
|
|
34
|
+
@_pending_app = App.new(host: default_host, port: default_port)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def app(host: nil, port: nil, &block)
|
|
38
|
+
host ||= default_host
|
|
39
|
+
port ||= default_port
|
|
40
|
+
return App.new(host: host, port: port).tap { |a| a.instance_eval(&block) } if block
|
|
41
|
+
|
|
42
|
+
pending = _pending_app
|
|
43
|
+
pending.set_endpoint!(host: host, port: port)
|
|
44
|
+
_reset_pending_app!
|
|
45
|
+
pending
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def page(**props, &block) = _pending_app.page(**props, &block)
|
|
49
|
+
def control(type, **props, &block) = _pending_app.control(type, **props, &block)
|
|
50
|
+
def widget(type, **props, &block) = _pending_app.widget(type, **props, &block)
|
|
51
|
+
def service(type, **props, &block) = _pending_app.service(type, **props, &block)
|
|
52
|
+
def column(**props, &block) = _pending_app.column(**props, &block)
|
|
53
|
+
def center(**props, &block) = _pending_app.center(**props, &block)
|
|
54
|
+
def row(**props, &block) = _pending_app.row(**props, &block)
|
|
55
|
+
def stack(**props, &block) = _pending_app.stack(**props, &block)
|
|
56
|
+
def grid_view(**props, &block) = _pending_app.grid_view(**props, &block)
|
|
57
|
+
def gridview(**props, &block) = _pending_app.gridview(**props, &block)
|
|
58
|
+
def container(**props, &block) = _pending_app.container(**props, &block)
|
|
59
|
+
def gesture_detector(**props, &block) = _pending_app.gesture_detector(**props, &block)
|
|
60
|
+
def gesturedetector(**props, &block) = _pending_app.gesturedetector(**props, &block)
|
|
61
|
+
def draggable(**props, &block) = _pending_app.draggable(**props, &block)
|
|
62
|
+
def drag_target(**props, &block) = _pending_app.drag_target(**props, &block)
|
|
63
|
+
def dragtarget(**props, &block) = _pending_app.dragtarget(**props, &block)
|
|
64
|
+
def text(value = nil, **props) = _pending_app.text(value, **props)
|
|
65
|
+
def button(**props) = _pending_app.button(**props)
|
|
66
|
+
def elevated_button(**props) = _pending_app.elevated_button(**props)
|
|
67
|
+
def text_field(**props) = _pending_app.text_field(**props)
|
|
68
|
+
def textfield(**props) = _pending_app.textfield(**props)
|
|
69
|
+
def icon(**props) = _pending_app.icon(**props)
|
|
70
|
+
def image(src = nil, **props) = _pending_app.image(src, **props)
|
|
71
|
+
def icon_button(**props) = _pending_app.icon_button(**props)
|
|
72
|
+
def iconbutton(**props) = _pending_app.iconbutton(**props)
|
|
73
|
+
def app_bar(**props) = _pending_app.app_bar(**props)
|
|
74
|
+
def appbar(**props) = _pending_app.appbar(**props)
|
|
75
|
+
def clipboard(**props) = _pending_app.clipboard(**props)
|
|
76
|
+
def text_button(**props) = _pending_app.text_button(**props)
|
|
77
|
+
def textbutton(**props) = _pending_app.textbutton(**props)
|
|
78
|
+
def filled_button(**props) = _pending_app.filled_button(**props)
|
|
79
|
+
def filledbutton(**props) = _pending_app.filledbutton(**props)
|
|
80
|
+
def checkbox(**props) = _pending_app.checkbox(**props)
|
|
81
|
+
def radio(**props) = _pending_app.radio(**props)
|
|
82
|
+
def radio_group(**props) = _pending_app.radio_group(**props)
|
|
83
|
+
def radiogroup(**props) = _pending_app.radiogroup(**props)
|
|
84
|
+
def alert_dialog(**props) = _pending_app.alert_dialog(**props)
|
|
85
|
+
def alertdialog(**props) = _pending_app.alertdialog(**props)
|
|
86
|
+
def snack_bar(**props) = _pending_app.snack_bar(**props)
|
|
87
|
+
def snackbar(**props) = _pending_app.snackbar(**props)
|
|
88
|
+
def bottom_sheet(**props) = _pending_app.bottom_sheet(**props)
|
|
89
|
+
def bottomsheet(**props) = _pending_app.bottomsheet(**props)
|
|
90
|
+
def markdown(value = nil, **props) = _pending_app.markdown(value, **props)
|
|
91
|
+
def floating_action_button(**props) = _pending_app.floating_action_button(**props)
|
|
92
|
+
def floatingactionbutton(**props) = _pending_app.floatingactionbutton(**props)
|
|
93
|
+
def tabs(**props, &block) = _pending_app.tabs(**props, &block)
|
|
94
|
+
def tab(**props, &block) = _pending_app.tab(**props, &block)
|
|
95
|
+
def tab_bar(**props, &block) = _pending_app.tab_bar(**props, &block)
|
|
96
|
+
def tabbar(**props, &block) = _pending_app.tabbar(**props, &block)
|
|
97
|
+
def tab_bar_view(**props, &block) = _pending_app.tab_bar_view(**props, &block)
|
|
98
|
+
def tabbarview(**props, &block) = _pending_app.tabbarview(**props, &block)
|
|
99
|
+
def navigation_bar(**props, &block) = _pending_app.navigation_bar(**props, &block)
|
|
100
|
+
def navigationbar(**props, &block) = _pending_app.navigationbar(**props, &block)
|
|
101
|
+
def navigation_bar_destination(**props, &block) = _pending_app.navigation_bar_destination(**props, &block)
|
|
102
|
+
def navigationbardestination(**props, &block) = _pending_app.navigationbardestination(**props, &block)
|
|
103
|
+
def bar_chart(**props) = _pending_app.bar_chart(**props)
|
|
104
|
+
def barchart(**props) = _pending_app.barchart(**props)
|
|
105
|
+
def bar_chart_group(**props) = _pending_app.bar_chart_group(**props)
|
|
106
|
+
def barchartgroup(**props) = _pending_app.barchartgroup(**props)
|
|
107
|
+
def bar_chart_rod(**props) = _pending_app.bar_chart_rod(**props)
|
|
108
|
+
def barchartrod(**props) = _pending_app.barchartrod(**props)
|
|
109
|
+
def bar_chart_rod_stack_item(**props) = _pending_app.bar_chart_rod_stack_item(**props)
|
|
110
|
+
def barchartrodstackitem(**props) = _pending_app.barchartrodstackitem(**props)
|
|
111
|
+
def line_chart(**props) = _pending_app.line_chart(**props)
|
|
112
|
+
def linechart(**props) = _pending_app.linechart(**props)
|
|
113
|
+
def line_chart_data(**props) = _pending_app.line_chart_data(**props)
|
|
114
|
+
def linechartdata(**props) = _pending_app.linechartdata(**props)
|
|
115
|
+
def line_chart_data_point(**props) = _pending_app.line_chart_data_point(**props)
|
|
116
|
+
def linechartdatapoint(**props) = _pending_app.linechartdatapoint(**props)
|
|
117
|
+
def pie_chart(**props) = _pending_app.pie_chart(**props)
|
|
118
|
+
def piechart(**props) = _pending_app.piechart(**props)
|
|
119
|
+
def pie_chart_section(**props) = _pending_app.pie_chart_section(**props)
|
|
120
|
+
def piechartsection(**props) = _pending_app.piechartsection(**props)
|
|
121
|
+
def candlestick_chart(**props) = _pending_app.candlestick_chart(**props)
|
|
122
|
+
def candlestickchart(**props) = _pending_app.candlestickchart(**props)
|
|
123
|
+
def candlestick_chart_spot(**props) = _pending_app.candlestick_chart_spot(**props)
|
|
124
|
+
def candlestickchartspot(**props) = _pending_app.candlestickchartspot(**props)
|
|
125
|
+
def radar_chart(**props) = _pending_app.radar_chart(**props)
|
|
126
|
+
def radarchart(**props) = _pending_app.radarchart(**props)
|
|
127
|
+
def radar_chart_title(**props) = _pending_app.radar_chart_title(**props)
|
|
128
|
+
def radarcharttitle(**props) = _pending_app.radarcharttitle(**props)
|
|
129
|
+
def radar_data_set(**props) = _pending_app.radar_data_set(**props)
|
|
130
|
+
def radardataset(**props) = _pending_app.radardataset(**props)
|
|
131
|
+
def radar_data_set_entry(**props) = _pending_app.radar_data_set_entry(**props)
|
|
132
|
+
def radardatasetentry(**props) = _pending_app.radardatasetentry(**props)
|
|
133
|
+
def scatter_chart(**props) = _pending_app.scatter_chart(**props)
|
|
134
|
+
def scatterchart(**props) = _pending_app.scatterchart(**props)
|
|
135
|
+
def scatter_chart_spot(**props) = _pending_app.scatter_chart_spot(**props)
|
|
136
|
+
def scatterchartspot(**props) = _pending_app.scatterchartspot(**props)
|
|
137
|
+
def chart_axis(**props) = _pending_app.chart_axis(**props)
|
|
138
|
+
def chartaxis(**props) = _pending_app.chartaxis(**props)
|
|
139
|
+
def chart_axis_label(**props) = _pending_app.chart_axis_label(**props)
|
|
140
|
+
def chartaxislabel(**props) = _pending_app.chartaxislabel(**props)
|
|
141
|
+
def web_view(**props) = _pending_app.web_view(**props)
|
|
142
|
+
def webview(**props) = _pending_app.webview(**props)
|
|
143
|
+
def fab(content = nil, **props) = _pending_app.fab(content, **props)
|
|
144
|
+
def cupertino_button(**props) = _pending_app.cupertino_button(**props)
|
|
145
|
+
def cupertinobutton(**props) = _pending_app.cupertinobutton(**props)
|
|
146
|
+
def cupertino_filled_button(**props) = _pending_app.cupertino_filled_button(**props)
|
|
147
|
+
def cupertinofilledbutton(**props) = _pending_app.cupertinofilledbutton(**props)
|
|
148
|
+
def cupertino_text_field(**props) = _pending_app.cupertino_text_field(**props)
|
|
149
|
+
def cupertinotextfield(**props) = _pending_app.cupertinotextfield(**props)
|
|
150
|
+
def cupertino_switch(**props) = _pending_app.cupertino_switch(**props)
|
|
151
|
+
def cupertinoswitch(**props) = _pending_app.cupertinoswitch(**props)
|
|
152
|
+
def cupertino_slider(**props) = _pending_app.cupertino_slider(**props)
|
|
153
|
+
def cupertinoslider(**props) = _pending_app.cupertinoslider(**props)
|
|
154
|
+
def cupertino_alert_dialog(**props) = _pending_app.cupertino_alert_dialog(**props)
|
|
155
|
+
def cupertinoalertdialog(**props) = _pending_app.cupertinoalertdialog(**props)
|
|
156
|
+
def cupertino_action_sheet(**props) = _pending_app.cupertino_action_sheet(**props)
|
|
157
|
+
def cupertinoactionsheet(**props) = _pending_app.cupertinoactionsheet(**props)
|
|
158
|
+
def cupertino_dialog_action(**props) = _pending_app.cupertino_dialog_action(**props)
|
|
159
|
+
def cupertinodialogaction(**props) = _pending_app.cupertinodialogaction(**props)
|
|
160
|
+
def cupertino_navigation_bar(**props) = _pending_app.cupertino_navigation_bar(**props)
|
|
161
|
+
def cupertinonavigationbar(**props) = _pending_app.cupertinonavigationbar(**props)
|
|
162
|
+
def duration(**parts) = duration_in_milliseconds(parts)
|
|
163
|
+
|
|
164
|
+
class App
|
|
165
|
+
include UI::ControlMethods
|
|
166
|
+
|
|
167
|
+
attr_reader :page_props, :host, :port
|
|
168
|
+
|
|
169
|
+
def initialize(host:, port:)
|
|
170
|
+
@host = host
|
|
171
|
+
@port = port
|
|
172
|
+
@roots = []
|
|
173
|
+
@services = []
|
|
174
|
+
@stack = []
|
|
175
|
+
@page_props = { "route" => "/" }
|
|
176
|
+
@seq = 0
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def set_endpoint!(host:, port:)
|
|
180
|
+
@host = host
|
|
181
|
+
@port = port
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def page(**props, &block)
|
|
185
|
+
@page_props.merge!(normalize_props(props))
|
|
186
|
+
instance_eval(&block) if block
|
|
187
|
+
self
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def widget(type, **props, &block)
|
|
191
|
+
control(type.to_s, **props, &block)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def control(type, **props, &block)
|
|
195
|
+
mapped_props = props.dup
|
|
196
|
+
prop_children = extract_children_prop(mapped_props)
|
|
197
|
+
|
|
198
|
+
id = mapped_props.delete(:id)&.to_s || next_id(type)
|
|
199
|
+
c = Ruflet::UI::ControlFactory.build(type.to_s, id: id, **normalize_props(mapped_props))
|
|
200
|
+
attach(c)
|
|
201
|
+
|
|
202
|
+
if block
|
|
203
|
+
@stack.push(c)
|
|
204
|
+
instance_eval(&block)
|
|
205
|
+
@stack.pop
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
if prop_children
|
|
209
|
+
Array(prop_children).each { |child| c.children << child if child.is_a?(Ruflet::Control) }
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
c
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def service(type, **props, &block)
|
|
216
|
+
mapped_props = props.dup
|
|
217
|
+
id = mapped_props.delete(:id)&.to_s || next_id(type)
|
|
218
|
+
svc = Ruflet::UI::ControlFactory.build(type.to_s, id: id, **normalize_props(mapped_props))
|
|
219
|
+
@services << svc unless @services.include?(svc)
|
|
220
|
+
svc
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def duration(**parts)
|
|
224
|
+
DSL.duration(**parts)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def run
|
|
228
|
+
app_roots = @roots
|
|
229
|
+
app_services = @services
|
|
230
|
+
page_props = @page_props.dup
|
|
231
|
+
|
|
232
|
+
Ruflet::Server.new(host: host, port: port) do |runtime_page|
|
|
233
|
+
runtime_page.set_view_props(page_props)
|
|
234
|
+
runtime_page.add_service(*app_services) if app_services.any?
|
|
235
|
+
runtime_page.add(*app_roots)
|
|
236
|
+
end.start
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
private
|
|
240
|
+
|
|
241
|
+
def build_widget(type, **props, &block) = control(type.to_s, **props, &block)
|
|
242
|
+
def build_service(type, **props, &block) = service(type.to_s, **props, &block)
|
|
243
|
+
|
|
244
|
+
def attach(control)
|
|
245
|
+
if @stack.empty?
|
|
246
|
+
@roots << control
|
|
247
|
+
else
|
|
248
|
+
@stack.last.children << control
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def normalize_props(hash)
|
|
253
|
+
hash.transform_keys(&:to_s).transform_values { |v| v.is_a?(Symbol) ? v.to_s : v }
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def extract_children_prop(props)
|
|
257
|
+
props.delete(:children) ||
|
|
258
|
+
props.delete("children") ||
|
|
259
|
+
props.delete(:controls) ||
|
|
260
|
+
props.delete("controls")
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def next_id(type)
|
|
264
|
+
@seq += 1
|
|
265
|
+
"#{type}_#{@seq}"
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def duration_in_milliseconds(parts)
|
|
269
|
+
DSL.send(:duration_in_milliseconds, parts)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def duration_in_milliseconds(parts)
|
|
275
|
+
return 0 if parts.nil? || parts.empty?
|
|
276
|
+
|
|
277
|
+
DURATION_FACTORS_MS.reduce(0.0) do |sum, (key, factor)|
|
|
278
|
+
sum + read_duration_part(parts, key) * factor
|
|
279
|
+
end.round
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def read_duration_part(parts, key)
|
|
283
|
+
raw = parts[key] || parts[key.to_s]
|
|
284
|
+
return 0.0 if raw.nil?
|
|
285
|
+
return raw.to_f if raw.is_a?(Numeric)
|
|
286
|
+
return raw.to_f if raw.is_a?(String) && raw.match?(/\A-?\d+(\.\d+)?\z/)
|
|
287
|
+
|
|
288
|
+
0.0
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require_relative "events/gesture_events"
|
|
5
|
+
|
|
6
|
+
module Ruflet
|
|
7
|
+
class Event
|
|
8
|
+
attr_reader :name, :target, :raw_data, :data, :typed_data, :page, :control
|
|
9
|
+
|
|
10
|
+
def initialize(name:, target:, raw_data:, page:, control:)
|
|
11
|
+
@name = name
|
|
12
|
+
@target = target
|
|
13
|
+
@raw_data = raw_data
|
|
14
|
+
@data = parse_data(raw_data)
|
|
15
|
+
@typed_data = Events::GestureEventFactory.build(name, @data)
|
|
16
|
+
@page = page
|
|
17
|
+
@control = control
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def parse_data(raw)
|
|
23
|
+
return raw unless raw.is_a?(String)
|
|
24
|
+
|
|
25
|
+
JSON.parse(raw)
|
|
26
|
+
rescue JSON::ParserError
|
|
27
|
+
raw
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
public
|
|
31
|
+
|
|
32
|
+
def method_missing(name, *args, &block)
|
|
33
|
+
return typed_data.public_send(name, *args, &block) if typed_data && typed_data.respond_to?(name)
|
|
34
|
+
|
|
35
|
+
super
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def respond_to_missing?(name, include_private = false)
|
|
39
|
+
(typed_data && typed_data.respond_to?(name, include_private)) || super
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|