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,552 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../types/geometry"
|
|
4
|
+
|
|
5
|
+
module Ruflet
|
|
6
|
+
module Events
|
|
7
|
+
class BasePayload
|
|
8
|
+
def self.pick(data, short, long)
|
|
9
|
+
return nil unless data.is_a?(Hash)
|
|
10
|
+
|
|
11
|
+
data[short] || data[short.to_sym] || data[long] || data[long.to_sym]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.offset(data, short, long)
|
|
15
|
+
UI::Types::Offset.from_wire(pick(data, short, long))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.duration(data, short, long)
|
|
19
|
+
UI::Types::Duration.from_wire(pick(data, short, long))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.stringify_keys(data)
|
|
23
|
+
return {} unless data.is_a?(Hash)
|
|
24
|
+
|
|
25
|
+
data.each_with_object({}) { |(k, v), out| out[k.to_s] = v }
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class GenericEvent < BasePayload
|
|
30
|
+
attr_reader :raw, :value
|
|
31
|
+
|
|
32
|
+
def initialize(raw:, value: nil)
|
|
33
|
+
@raw = raw
|
|
34
|
+
@value = value
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.from_data(data)
|
|
38
|
+
raw = data.is_a?(Hash) ? stringify_keys(data) : data
|
|
39
|
+
value =
|
|
40
|
+
if raw.is_a?(Hash)
|
|
41
|
+
raw["value"] || raw["v"] || raw["data"] || raw["state"]
|
|
42
|
+
else
|
|
43
|
+
raw
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
new(raw: raw, value: value)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class ChangeEvent < GenericEvent; end
|
|
51
|
+
class FocusEvent < GenericEvent; end
|
|
52
|
+
class BlurEvent < GenericEvent; end
|
|
53
|
+
class ClickEvent < GenericEvent; end
|
|
54
|
+
class SubmitEvent < GenericEvent; end
|
|
55
|
+
class SelectEvent < GenericEvent; end
|
|
56
|
+
class DismissEvent < GenericEvent; end
|
|
57
|
+
class VisibleEvent < GenericEvent; end
|
|
58
|
+
class ResultEvent < GenericEvent; end
|
|
59
|
+
class UploadEvent < GenericEvent; end
|
|
60
|
+
class ErrorEvent < GenericEvent; end
|
|
61
|
+
class ActionEvent < GenericEvent; end
|
|
62
|
+
class StateChangeEvent < GenericEvent
|
|
63
|
+
attr_reader :state
|
|
64
|
+
|
|
65
|
+
def initialize(raw:, value: nil, state: nil)
|
|
66
|
+
super(raw: raw, value: value)
|
|
67
|
+
@state = state
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.from_data(data)
|
|
71
|
+
raw = data.is_a?(Hash) ? stringify_keys(data) : {}
|
|
72
|
+
state = raw["state"] || raw["value"] || raw["v"] || data
|
|
73
|
+
new(raw: raw, value: state, state: state)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
class TapEvent < BasePayload
|
|
78
|
+
attr_reader :kind, :local_position, :global_position
|
|
79
|
+
|
|
80
|
+
def initialize(kind:, local_position:, global_position:)
|
|
81
|
+
@kind = kind
|
|
82
|
+
@local_position = local_position
|
|
83
|
+
@global_position = global_position
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def self.from_data(data)
|
|
87
|
+
new(
|
|
88
|
+
kind: pick(data, "k", "kind"),
|
|
89
|
+
local_position: offset(data, "l", "local_position"),
|
|
90
|
+
global_position: offset(data, "g", "global_position")
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class TapMoveEvent < BasePayload
|
|
96
|
+
attr_reader :kind, :local_position, :global_position, :delta
|
|
97
|
+
|
|
98
|
+
def initialize(kind:, local_position:, global_position:, delta:)
|
|
99
|
+
@kind = kind
|
|
100
|
+
@local_position = local_position
|
|
101
|
+
@global_position = global_position
|
|
102
|
+
@delta = delta
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def self.from_data(data)
|
|
106
|
+
new(
|
|
107
|
+
kind: pick(data, "k", "kind"),
|
|
108
|
+
local_position: offset(data, "l", "local_position"),
|
|
109
|
+
global_position: offset(data, "g", "global_position"),
|
|
110
|
+
delta: offset(data, "d", "delta")
|
|
111
|
+
)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
class MultiTapEvent < BasePayload
|
|
116
|
+
attr_reader :correct_touches
|
|
117
|
+
|
|
118
|
+
def initialize(correct_touches:)
|
|
119
|
+
@correct_touches = correct_touches
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def self.from_data(data)
|
|
123
|
+
new(correct_touches: pick(data, "ct", "correct_touches"))
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
class LongPressDownEvent < BasePayload
|
|
128
|
+
attr_reader :kind, :local_position, :global_position
|
|
129
|
+
|
|
130
|
+
def initialize(kind:, local_position:, global_position:)
|
|
131
|
+
@kind = kind
|
|
132
|
+
@local_position = local_position
|
|
133
|
+
@global_position = global_position
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def self.from_data(data)
|
|
137
|
+
new(
|
|
138
|
+
kind: pick(data, "k", "kind"),
|
|
139
|
+
local_position: offset(data, "l", "local_position"),
|
|
140
|
+
global_position: offset(data, "g", "global_position")
|
|
141
|
+
)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
class LongPressStartEvent < BasePayload
|
|
146
|
+
attr_reader :local_position, :global_position
|
|
147
|
+
|
|
148
|
+
def initialize(local_position:, global_position:)
|
|
149
|
+
@local_position = local_position
|
|
150
|
+
@global_position = global_position
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def self.from_data(data)
|
|
154
|
+
new(
|
|
155
|
+
local_position: offset(data, "l", "local_position"),
|
|
156
|
+
global_position: offset(data, "g", "global_position")
|
|
157
|
+
)
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
class LongPressMoveUpdateEvent < BasePayload
|
|
162
|
+
attr_reader :local_position, :global_position, :offset_from_origin, :local_offset_from_origin
|
|
163
|
+
|
|
164
|
+
def initialize(local_position:, global_position:, offset_from_origin:, local_offset_from_origin:)
|
|
165
|
+
@local_position = local_position
|
|
166
|
+
@global_position = global_position
|
|
167
|
+
@offset_from_origin = offset_from_origin
|
|
168
|
+
@local_offset_from_origin = local_offset_from_origin
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def self.from_data(data)
|
|
172
|
+
new(
|
|
173
|
+
local_position: offset(data, "l", "local_position"),
|
|
174
|
+
global_position: offset(data, "g", "global_position"),
|
|
175
|
+
offset_from_origin: offset(data, "of", "offset_from_origin"),
|
|
176
|
+
local_offset_from_origin: offset(data, "lofo", "local_offset_from_origin")
|
|
177
|
+
)
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
class LongPressEndEvent < BasePayload
|
|
182
|
+
attr_reader :local_position, :global_position, :velocity
|
|
183
|
+
|
|
184
|
+
def initialize(local_position:, global_position:, velocity:)
|
|
185
|
+
@local_position = local_position
|
|
186
|
+
@global_position = global_position
|
|
187
|
+
@velocity = velocity
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def self.from_data(data)
|
|
191
|
+
new(
|
|
192
|
+
local_position: offset(data, "l", "local_position"),
|
|
193
|
+
global_position: offset(data, "g", "global_position"),
|
|
194
|
+
velocity: offset(data, "v", "velocity")
|
|
195
|
+
)
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
class DragDownEvent < BasePayload
|
|
200
|
+
attr_reader :local_position, :global_position
|
|
201
|
+
|
|
202
|
+
def initialize(local_position:, global_position:)
|
|
203
|
+
@local_position = local_position
|
|
204
|
+
@global_position = global_position
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def self.from_data(data)
|
|
208
|
+
new(
|
|
209
|
+
local_position: offset(data, "l", "local_position"),
|
|
210
|
+
global_position: offset(data, "g", "global_position")
|
|
211
|
+
)
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
class DragStartEvent < BasePayload
|
|
216
|
+
attr_reader :kind, :local_position, :global_position, :timestamp
|
|
217
|
+
|
|
218
|
+
def initialize(kind:, local_position:, global_position:, timestamp:)
|
|
219
|
+
@kind = kind
|
|
220
|
+
@local_position = local_position
|
|
221
|
+
@global_position = global_position
|
|
222
|
+
@timestamp = timestamp
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def self.from_data(data)
|
|
226
|
+
new(
|
|
227
|
+
kind: pick(data, "k", "kind"),
|
|
228
|
+
local_position: offset(data, "l", "local_position"),
|
|
229
|
+
global_position: offset(data, "g", "global_position"),
|
|
230
|
+
timestamp: duration(data, "ts", "timestamp")
|
|
231
|
+
)
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
class DragUpdateEvent < BasePayload
|
|
236
|
+
attr_reader :local_position, :global_position, :local_delta, :global_delta, :primary_delta, :timestamp
|
|
237
|
+
|
|
238
|
+
def initialize(local_position:, global_position:, local_delta:, global_delta:, primary_delta:, timestamp:)
|
|
239
|
+
@local_position = local_position
|
|
240
|
+
@global_position = global_position
|
|
241
|
+
@local_delta = local_delta
|
|
242
|
+
@global_delta = global_delta
|
|
243
|
+
@primary_delta = primary_delta
|
|
244
|
+
@timestamp = timestamp
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
def self.from_data(data)
|
|
248
|
+
new(
|
|
249
|
+
local_position: offset(data, "l", "local_position"),
|
|
250
|
+
global_position: offset(data, "g", "global_position"),
|
|
251
|
+
local_delta: offset(data, "ld", "local_delta"),
|
|
252
|
+
global_delta: offset(data, "gd", "global_delta"),
|
|
253
|
+
primary_delta: pick(data, "pd", "primary_delta"),
|
|
254
|
+
timestamp: duration(data, "ts", "timestamp")
|
|
255
|
+
)
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
class DragEndEvent < BasePayload
|
|
260
|
+
attr_reader :local_position, :global_position, :velocity, :primary_velocity
|
|
261
|
+
|
|
262
|
+
def initialize(local_position:, global_position:, velocity:, primary_velocity:)
|
|
263
|
+
@local_position = local_position
|
|
264
|
+
@global_position = global_position
|
|
265
|
+
@velocity = velocity
|
|
266
|
+
@primary_velocity = primary_velocity
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
def self.from_data(data)
|
|
270
|
+
new(
|
|
271
|
+
local_position: offset(data, "l", "local_position"),
|
|
272
|
+
global_position: offset(data, "g", "global_position"),
|
|
273
|
+
velocity: offset(data, "v", "velocity"),
|
|
274
|
+
primary_velocity: pick(data, "pv", "primary_velocity")
|
|
275
|
+
)
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
class ForcePressEvent < BasePayload
|
|
280
|
+
attr_reader :local_position, :global_position, :pressure
|
|
281
|
+
|
|
282
|
+
def initialize(local_position:, global_position:, pressure:)
|
|
283
|
+
@local_position = local_position
|
|
284
|
+
@global_position = global_position
|
|
285
|
+
@pressure = pressure
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
def self.from_data(data)
|
|
289
|
+
new(
|
|
290
|
+
local_position: offset(data, "l", "local_position"),
|
|
291
|
+
global_position: offset(data, "g", "global_position"),
|
|
292
|
+
pressure: pick(data, "p", "pressure")
|
|
293
|
+
)
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
class ScaleStartEvent < BasePayload
|
|
298
|
+
attr_reader :local_focal_point, :global_focal_point, :pointer_count, :timestamp
|
|
299
|
+
|
|
300
|
+
def initialize(local_focal_point:, global_focal_point:, pointer_count:, timestamp:)
|
|
301
|
+
@local_focal_point = local_focal_point
|
|
302
|
+
@global_focal_point = global_focal_point
|
|
303
|
+
@pointer_count = pointer_count
|
|
304
|
+
@timestamp = timestamp
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
def self.from_data(data)
|
|
308
|
+
new(
|
|
309
|
+
local_focal_point: offset(data, "lfp", "local_focal_point"),
|
|
310
|
+
global_focal_point: offset(data, "gfp", "global_focal_point"),
|
|
311
|
+
pointer_count: pick(data, "pc", "pointer_count"),
|
|
312
|
+
timestamp: duration(data, "ts", "timestamp")
|
|
313
|
+
)
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
class ScaleUpdateEvent < BasePayload
|
|
318
|
+
attr_reader :local_focal_point, :global_focal_point, :focal_point_delta,
|
|
319
|
+
:pointer_count, :horizontal_scale, :vertical_scale, :scale,
|
|
320
|
+
:rotation, :timestamp
|
|
321
|
+
|
|
322
|
+
def initialize(local_focal_point:, global_focal_point:, focal_point_delta:, pointer_count:, horizontal_scale:, vertical_scale:, scale:, rotation:, timestamp:)
|
|
323
|
+
@local_focal_point = local_focal_point
|
|
324
|
+
@global_focal_point = global_focal_point
|
|
325
|
+
@focal_point_delta = focal_point_delta
|
|
326
|
+
@pointer_count = pointer_count
|
|
327
|
+
@horizontal_scale = horizontal_scale
|
|
328
|
+
@vertical_scale = vertical_scale
|
|
329
|
+
@scale = scale
|
|
330
|
+
@rotation = rotation
|
|
331
|
+
@timestamp = timestamp
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def self.from_data(data)
|
|
335
|
+
new(
|
|
336
|
+
local_focal_point: offset(data, "lfp", "local_focal_point"),
|
|
337
|
+
global_focal_point: offset(data, "gfp", "global_focal_point"),
|
|
338
|
+
focal_point_delta: offset(data, "fpd", "focal_point_delta"),
|
|
339
|
+
pointer_count: pick(data, "pc", "pointer_count"),
|
|
340
|
+
horizontal_scale: pick(data, "hs", "horizontal_scale"),
|
|
341
|
+
vertical_scale: pick(data, "vs", "vertical_scale"),
|
|
342
|
+
scale: pick(data, "s", "scale"),
|
|
343
|
+
rotation: pick(data, "rot", "rotation"),
|
|
344
|
+
timestamp: duration(data, "ts", "timestamp")
|
|
345
|
+
)
|
|
346
|
+
end
|
|
347
|
+
end
|
|
348
|
+
|
|
349
|
+
class ScaleEndEvent < BasePayload
|
|
350
|
+
attr_reader :pointer_count, :velocity
|
|
351
|
+
|
|
352
|
+
def initialize(pointer_count:, velocity:)
|
|
353
|
+
@pointer_count = pointer_count
|
|
354
|
+
@velocity = velocity
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
def self.from_data(data)
|
|
358
|
+
new(
|
|
359
|
+
pointer_count: pick(data, "pc", "pointer_count"),
|
|
360
|
+
velocity: offset(data, "v", "velocity")
|
|
361
|
+
)
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
class PointerEvent < BasePayload
|
|
366
|
+
attr_reader :kind, :local_position, :global_position, :timestamp,
|
|
367
|
+
:device, :pressure, :pressure_min, :pressure_max, :distance,
|
|
368
|
+
:distance_max, :size, :radius_major, :radius_minor,
|
|
369
|
+
:radius_min, :radius_max, :orientation, :tilt,
|
|
370
|
+
:local_delta, :global_delta
|
|
371
|
+
|
|
372
|
+
def initialize(kind:, local_position:, global_position:, timestamp:, device:, pressure:, pressure_min:, pressure_max:, distance:, distance_max:, size:, radius_major:, radius_minor:, radius_min:, radius_max:, orientation:, tilt:, local_delta:, global_delta:)
|
|
373
|
+
@kind = kind
|
|
374
|
+
@local_position = local_position
|
|
375
|
+
@global_position = global_position
|
|
376
|
+
@timestamp = timestamp
|
|
377
|
+
@device = device
|
|
378
|
+
@pressure = pressure
|
|
379
|
+
@pressure_min = pressure_min
|
|
380
|
+
@pressure_max = pressure_max
|
|
381
|
+
@distance = distance
|
|
382
|
+
@distance_max = distance_max
|
|
383
|
+
@size = size
|
|
384
|
+
@radius_major = radius_major
|
|
385
|
+
@radius_minor = radius_minor
|
|
386
|
+
@radius_min = radius_min
|
|
387
|
+
@radius_max = radius_max
|
|
388
|
+
@orientation = orientation
|
|
389
|
+
@tilt = tilt
|
|
390
|
+
@local_delta = local_delta
|
|
391
|
+
@global_delta = global_delta
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
def self.from_data(data)
|
|
395
|
+
new(
|
|
396
|
+
kind: pick(data, "k", "kind"),
|
|
397
|
+
local_position: offset(data, "l", "local_position"),
|
|
398
|
+
global_position: offset(data, "g", "global_position"),
|
|
399
|
+
timestamp: duration(data, "ts", "timestamp"),
|
|
400
|
+
device: pick(data, "dev", "device"),
|
|
401
|
+
pressure: pick(data, "ps", "pressure"),
|
|
402
|
+
pressure_min: pick(data, "pMin", "pressure_min"),
|
|
403
|
+
pressure_max: pick(data, "pMax", "pressure_max"),
|
|
404
|
+
distance: pick(data, "dist", "distance"),
|
|
405
|
+
distance_max: pick(data, "distMax", "distance_max"),
|
|
406
|
+
size: pick(data, "size", "size"),
|
|
407
|
+
radius_major: pick(data, "rMj", "radius_major"),
|
|
408
|
+
radius_minor: pick(data, "rMn", "radius_minor"),
|
|
409
|
+
radius_min: pick(data, "rMin", "radius_min"),
|
|
410
|
+
radius_max: pick(data, "rMax", "radius_max"),
|
|
411
|
+
orientation: pick(data, "or", "orientation"),
|
|
412
|
+
tilt: pick(data, "tilt", "tilt"),
|
|
413
|
+
local_delta: offset(data, "ld", "local_delta"),
|
|
414
|
+
global_delta: offset(data, "gd", "global_delta")
|
|
415
|
+
)
|
|
416
|
+
end
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
HoverEvent = PointerEvent
|
|
420
|
+
|
|
421
|
+
class ScrollEvent < BasePayload
|
|
422
|
+
attr_reader :local_position, :global_position, :scroll_delta
|
|
423
|
+
|
|
424
|
+
def initialize(local_position:, global_position:, scroll_delta:)
|
|
425
|
+
@local_position = local_position
|
|
426
|
+
@global_position = global_position
|
|
427
|
+
@scroll_delta = scroll_delta
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
def self.from_data(data)
|
|
431
|
+
new(
|
|
432
|
+
local_position: offset(data, "l", "local_position"),
|
|
433
|
+
global_position: offset(data, "g", "global_position"),
|
|
434
|
+
scroll_delta: offset(data, "sd", "scroll_delta")
|
|
435
|
+
)
|
|
436
|
+
end
|
|
437
|
+
end
|
|
438
|
+
|
|
439
|
+
module GestureEventFactory
|
|
440
|
+
module_function
|
|
441
|
+
|
|
442
|
+
EVENT_CLASS_MAP = {
|
|
443
|
+
"change" => ChangeEvent,
|
|
444
|
+
"focus" => FocusEvent,
|
|
445
|
+
"blur" => BlurEvent,
|
|
446
|
+
"click" => ClickEvent,
|
|
447
|
+
"submit" => SubmitEvent,
|
|
448
|
+
"select" => SelectEvent,
|
|
449
|
+
"dismiss" => DismissEvent,
|
|
450
|
+
"visible" => VisibleEvent,
|
|
451
|
+
"result" => ResultEvent,
|
|
452
|
+
"upload" => UploadEvent,
|
|
453
|
+
"error" => ErrorEvent,
|
|
454
|
+
"action" => ActionEvent,
|
|
455
|
+
"state_change" => StateChangeEvent,
|
|
456
|
+
"confirm_pop" => GenericEvent,
|
|
457
|
+
"route_change" => GenericEvent,
|
|
458
|
+
"view_pop" => GenericEvent,
|
|
459
|
+
"animation_end" => GenericEvent,
|
|
460
|
+
"size_change" => GenericEvent,
|
|
461
|
+
"selection_change" => GenericEvent,
|
|
462
|
+
"entry_mode_change" => GenericEvent,
|
|
463
|
+
"media_change" => GenericEvent,
|
|
464
|
+
"resize" => GenericEvent,
|
|
465
|
+
"load" => GenericEvent,
|
|
466
|
+
"loaded" => GenericEvent,
|
|
467
|
+
"accept" => GenericEvent,
|
|
468
|
+
"will_accept" => GenericEvent,
|
|
469
|
+
"accept_with_details" => GenericEvent,
|
|
470
|
+
"move" => GenericEvent,
|
|
471
|
+
"leave" => GenericEvent,
|
|
472
|
+
"open" => GenericEvent,
|
|
473
|
+
"close" => GenericEvent,
|
|
474
|
+
"double_tap" => GenericEvent,
|
|
475
|
+
"double_tap_down" => TapEvent,
|
|
476
|
+
"tap_up" => TapEvent,
|
|
477
|
+
"tap_cancel" => GenericEvent,
|
|
478
|
+
"tap" => TapEvent,
|
|
479
|
+
"tap_down" => TapEvent,
|
|
480
|
+
"tap_move" => TapMoveEvent,
|
|
481
|
+
"multi_tap" => MultiTapEvent,
|
|
482
|
+
"multi_long_press" => GenericEvent,
|
|
483
|
+
"long_press_down" => LongPressDownEvent,
|
|
484
|
+
"long_press_cancel" => GenericEvent,
|
|
485
|
+
"long_press" => GenericEvent,
|
|
486
|
+
"long_press_start" => LongPressStartEvent,
|
|
487
|
+
"long_press_move_update" => LongPressMoveUpdateEvent,
|
|
488
|
+
"long_press_up" => GenericEvent,
|
|
489
|
+
"long_press_end" => LongPressEndEvent,
|
|
490
|
+
"secondary_tap" => TapEvent,
|
|
491
|
+
"secondary_tap_down" => TapEvent,
|
|
492
|
+
"secondary_tap_up" => TapEvent,
|
|
493
|
+
"secondary_tap_cancel" => GenericEvent,
|
|
494
|
+
"tertiary_tap_down" => TapEvent,
|
|
495
|
+
"tertiary_tap_up" => TapEvent,
|
|
496
|
+
"tertiary_tap_cancel" => GenericEvent,
|
|
497
|
+
"secondary_long_press_down" => LongPressDownEvent,
|
|
498
|
+
"secondary_long_press_cancel" => GenericEvent,
|
|
499
|
+
"secondary_long_press" => GenericEvent,
|
|
500
|
+
"secondary_long_press_start" => LongPressStartEvent,
|
|
501
|
+
"secondary_long_press_move_update" => LongPressMoveUpdateEvent,
|
|
502
|
+
"secondary_long_press_up" => GenericEvent,
|
|
503
|
+
"secondary_long_press_end" => LongPressEndEvent,
|
|
504
|
+
"tertiary_long_press_down" => LongPressDownEvent,
|
|
505
|
+
"tertiary_long_press_cancel" => GenericEvent,
|
|
506
|
+
"tertiary_long_press" => GenericEvent,
|
|
507
|
+
"tertiary_long_press_start" => LongPressStartEvent,
|
|
508
|
+
"tertiary_long_press_move_update" => LongPressMoveUpdateEvent,
|
|
509
|
+
"tertiary_long_press_up" => GenericEvent,
|
|
510
|
+
"tertiary_long_press_end" => LongPressEndEvent,
|
|
511
|
+
"drag_down" => DragDownEvent,
|
|
512
|
+
"horizontal_drag_down" => DragDownEvent,
|
|
513
|
+
"horizontal_drag_cancel" => GenericEvent,
|
|
514
|
+
"pan_start" => DragStartEvent,
|
|
515
|
+
"pan_update" => DragUpdateEvent,
|
|
516
|
+
"pan_end" => DragEndEvent,
|
|
517
|
+
"pan_down" => DragDownEvent,
|
|
518
|
+
"pan_cancel" => GenericEvent,
|
|
519
|
+
"horizontal_drag_start" => DragStartEvent,
|
|
520
|
+
"horizontal_drag_update" => DragUpdateEvent,
|
|
521
|
+
"horizontal_drag_end" => DragEndEvent,
|
|
522
|
+
"vertical_drag_down" => DragDownEvent,
|
|
523
|
+
"vertical_drag_cancel" => GenericEvent,
|
|
524
|
+
"vertical_drag_start" => DragStartEvent,
|
|
525
|
+
"vertical_drag_update" => DragUpdateEvent,
|
|
526
|
+
"vertical_drag_end" => DragEndEvent,
|
|
527
|
+
"right_pan_start" => DragStartEvent,
|
|
528
|
+
"right_pan_update" => DragUpdateEvent,
|
|
529
|
+
"right_pan_end" => DragEndEvent,
|
|
530
|
+
"force_press" => ForcePressEvent,
|
|
531
|
+
"force_press_start" => ForcePressEvent,
|
|
532
|
+
"force_press_peak" => ForcePressEvent,
|
|
533
|
+
"force_press_update" => ForcePressEvent,
|
|
534
|
+
"force_press_end" => ForcePressEvent,
|
|
535
|
+
"scale_start" => ScaleStartEvent,
|
|
536
|
+
"scale_update" => ScaleUpdateEvent,
|
|
537
|
+
"scale_end" => ScaleEndEvent,
|
|
538
|
+
"hover" => PointerEvent,
|
|
539
|
+
"enter" => PointerEvent,
|
|
540
|
+
"exit" => PointerEvent,
|
|
541
|
+
"scroll" => ScrollEvent
|
|
542
|
+
}.freeze
|
|
543
|
+
|
|
544
|
+
def build(name, data)
|
|
545
|
+
klass = EVENT_CLASS_MAP[name.to_s]
|
|
546
|
+
return nil unless klass
|
|
547
|
+
|
|
548
|
+
klass.from_data(data)
|
|
549
|
+
end
|
|
550
|
+
end
|
|
551
|
+
end
|
|
552
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
begin
|
|
4
|
+
require_relative "icons/material_icon_lookup"
|
|
5
|
+
require_relative "icons/cupertino_icon_lookup"
|
|
6
|
+
rescue StandardError
|
|
7
|
+
nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module Ruflet
|
|
11
|
+
class IconData
|
|
12
|
+
attr_reader :value
|
|
13
|
+
|
|
14
|
+
def initialize(value)
|
|
15
|
+
@value = normalize(value)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def ==(other)
|
|
19
|
+
other_value = other.is_a?(IconData) ? other.value : self.class.new(other).value
|
|
20
|
+
if value.is_a?(Integer) && other_value.is_a?(Integer)
|
|
21
|
+
value == other_value
|
|
22
|
+
elsif value.is_a?(String) && other_value.is_a?(String)
|
|
23
|
+
value.casecmp?(other_value)
|
|
24
|
+
else
|
|
25
|
+
value == other_value
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def eql?(other)
|
|
30
|
+
self == other
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def hash
|
|
34
|
+
value.is_a?(String) ? value.downcase.hash : value.hash
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def to_s
|
|
38
|
+
value.to_s
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def normalize(input)
|
|
44
|
+
return input.value if input.is_a?(IconData)
|
|
45
|
+
if input.is_a?(Integer)
|
|
46
|
+
codepoint = Ruflet::MaterialIconLookup.codepoint_for(input)
|
|
47
|
+
codepoint = Ruflet::CupertinoIconLookup.codepoint_for(input) if codepoint == input
|
|
48
|
+
return codepoint
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
raw = input.to_s
|
|
52
|
+
raw = raw.strip if raw.respond_to?(:strip)
|
|
53
|
+
return raw if raw.empty?
|
|
54
|
+
|
|
55
|
+
codepoint = Ruflet::MaterialIconLookup.codepoint_for(raw)
|
|
56
|
+
codepoint = Ruflet::CupertinoIconLookup.codepoint_for(raw) if codepoint.nil?
|
|
57
|
+
return codepoint unless codepoint.nil?
|
|
58
|
+
|
|
59
|
+
raw
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../icon_data"
|
|
4
|
+
require_relative "../cupertino_icon_lookup"
|
|
5
|
+
|
|
6
|
+
module Ruflet
|
|
7
|
+
module CupertinoIcons
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
ICONS = begin
|
|
11
|
+
source = Ruflet::CupertinoIconLookup.icon_map
|
|
12
|
+
if source.empty?
|
|
13
|
+
{
|
|
14
|
+
HOME: "house",
|
|
15
|
+
SEARCH: "search",
|
|
16
|
+
SETTINGS: "gear",
|
|
17
|
+
ADD: "add",
|
|
18
|
+
CLOSE: "clear"
|
|
19
|
+
}
|
|
20
|
+
else
|
|
21
|
+
source.keys.each_with_object({}) do |name, result|
|
|
22
|
+
text = name.to_s.gsub(/[^a-zA-Z0-9]/, "_").gsub(/_+/, "_").sub(/\A_/, "").sub(/_\z/, "")
|
|
23
|
+
text = "ICON_#{text}" if text.match?(/\A\d/)
|
|
24
|
+
result[text.upcase.to_sym] = name
|
|
25
|
+
end
|
|
26
|
+
end.freeze
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
ICONS.each do |const_name, icon_name|
|
|
30
|
+
next if const_defined?(const_name, false)
|
|
31
|
+
|
|
32
|
+
const_set(const_name, Ruflet::IconData.new(icon_name))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def [](name)
|
|
36
|
+
key = name.to_s.upcase.to_sym
|
|
37
|
+
return const_get(key) if const_defined?(key, false)
|
|
38
|
+
|
|
39
|
+
Ruflet::IconData.new(name.to_s)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def all
|
|
43
|
+
ICONS.keys.map { |k| const_get(k) }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def random
|
|
47
|
+
all.sample || Ruflet::IconData.new(Ruflet::CupertinoIconLookup.fallback_codepoint)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def names
|
|
51
|
+
ICONS.values
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|