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.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -30
  3. data/lib/ruflet/version.rb +1 -1
  4. data/lib/ruflet_core.rb +9 -7
  5. data/lib/ruflet_protocol/ruflet/protocol.rb +28 -54
  6. data/lib/ruflet_ui/ruflet/app.rb +1 -1
  7. data/lib/ruflet_ui/ruflet/colors.rb +4 -50
  8. data/lib/ruflet_ui/ruflet/control.rb +69 -64
  9. data/lib/ruflet_ui/ruflet/dsl.rb +10 -3
  10. data/lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb +2 -2
  11. data/lib/ruflet_ui/ruflet/icons/cupertino_icon_lookup.rb +1 -0
  12. data/lib/ruflet_ui/ruflet/icons/icon_constant_names.rb +29 -0
  13. data/lib/ruflet_ui/ruflet/icons/material/material_icons.rb +2 -2
  14. data/lib/ruflet_ui/ruflet/icons/material_icon_lookup.rb +1 -0
  15. data/lib/ruflet_ui/ruflet/page.rb +308 -526
  16. data/lib/ruflet_ui/ruflet/ui/control_factory.rb +68 -12
  17. data/lib/ruflet_ui/ruflet/ui/control_registry.rb +13 -6
  18. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactionsheet_control.rb +8 -45
  19. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactionsheetaction_control.rb +45 -2
  20. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoactivityindicator_control.rb +43 -2
  21. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoalertdialog_control.rb +0 -5
  22. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinobutton_control.rb +59 -4
  23. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocheckbox_control.rb +56 -1
  24. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocontextmenu_control.rb +1 -3
  25. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinocontextmenuaction_control.rb +1 -1
  26. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinodatepicker_control.rb +53 -8
  27. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinodialogaction_control.rb +1 -1
  28. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinofilledbutton_control.rb +59 -4
  29. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinolisttile_control.rb +54 -9
  30. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinonavigationbar_control.rb +47 -9
  31. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinopicker_control.rb +52 -10
  32. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoradio_control.rb +52 -1
  33. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinosegmentedbutton_control.rb +49 -1
  34. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoslider_control.rb +50 -5
  35. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoslidingsegmentedbutton_control.rb +46 -1
  36. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinoswitch_control.rb +61 -1
  37. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotextfield_control.rb +145 -1
  38. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotimerpicker_control.rb +47 -12
  39. data/lib/ruflet_ui/ruflet/ui/controls/cupertinos/cupertinotintedbutton_control.rb +59 -4
  40. data/lib/ruflet_ui/ruflet/ui/controls/materials/alertdialog_control.rb +8 -45
  41. data/lib/ruflet_ui/ruflet/ui/controls/materials/appbar_control.rb +8 -40
  42. data/lib/ruflet_ui/ruflet/ui/controls/materials/audio_control.rb +16 -5
  43. data/lib/ruflet_ui/ruflet/ui/controls/materials/autocomplete_control.rb +44 -1
  44. data/lib/ruflet_ui/ruflet/ui/controls/materials/badge_control.rb +0 -7
  45. data/lib/ruflet_ui/ruflet/ui/controls/materials/banner_control.rb +0 -7
  46. data/lib/ruflet_ui/ruflet/ui/controls/materials/bottomappbar_control.rb +8 -47
  47. data/lib/ruflet_ui/ruflet/ui/controls/materials/bottomsheet_control.rb +0 -3
  48. data/lib/ruflet_ui/ruflet/ui/controls/materials/button_control.rb +8 -54
  49. data/lib/ruflet_ui/ruflet/ui/controls/materials/card_control.rb +8 -50
  50. data/lib/ruflet_ui/ruflet/ui/controls/materials/chart_controls.rb +19 -0
  51. data/lib/ruflet_ui/ruflet/ui/controls/materials/checkbox_control.rb +9 -60
  52. data/lib/ruflet_ui/ruflet/ui/controls/materials/chip_control.rb +7 -81
  53. data/lib/ruflet_ui/ruflet/ui/controls/materials/circleavatar_control.rb +7 -56
  54. data/lib/ruflet_ui/ruflet/ui/controls/materials/container_control.rb +9 -65
  55. data/lib/ruflet_ui/ruflet/ui/controls/materials/contextmenu_control.rb +50 -4
  56. data/lib/ruflet_ui/ruflet/ui/controls/materials/datacell_control.rb +1 -3
  57. data/lib/ruflet_ui/ruflet/ui/controls/materials/datacolumn_control.rb +1 -3
  58. data/lib/ruflet_ui/ruflet/ui/controls/materials/datatable_control.rb +7 -88
  59. data/lib/ruflet_ui/ruflet/ui/controls/materials/datepicker_control.rb +9 -55
  60. data/lib/ruflet_ui/ruflet/ui/controls/materials/daterangepicker_control.rb +8 -58
  61. data/lib/ruflet_ui/ruflet/ui/controls/materials/divider_control.rb +0 -9
  62. data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdown_control.rb +8 -93
  63. data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdownm2_control.rb +9 -103
  64. data/lib/ruflet_ui/ruflet/ui/controls/materials/dropdownoption_control.rb +0 -2
  65. data/lib/ruflet_ui/ruflet/ui/controls/materials/expansionpanel_control.rb +7 -51
  66. data/lib/ruflet_ui/ruflet/ui/controls/materials/expansionpanellist_control.rb +46 -5
  67. data/lib/ruflet_ui/ruflet/ui/controls/materials/expansiontile_control.rb +69 -3
  68. data/lib/ruflet_ui/ruflet/ui/controls/materials/filledbutton_control.rb +54 -2
  69. data/lib/ruflet_ui/ruflet/ui/controls/materials/fillediconbutton_control.rb +67 -5
  70. data/lib/ruflet_ui/ruflet/ui/controls/materials/filledtonalbutton_control.rb +54 -2
  71. data/lib/ruflet_ui/ruflet/ui/controls/materials/filledtonaliconbutton_control.rb +67 -5
  72. data/lib/ruflet_ui/ruflet/ui/controls/materials/floatingactionbutton_control.rb +7 -69
  73. data/lib/ruflet_ui/ruflet/ui/controls/materials/iconbutton_control.rb +8 -68
  74. data/lib/ruflet_ui/ruflet/ui/controls/materials/listtile_control.rb +8 -74
  75. data/lib/ruflet_ui/ruflet/ui/controls/materials/map_control.rb +99 -0
  76. data/lib/ruflet_ui/ruflet/ui/controls/materials/menuitembutton_control.rb +8 -56
  77. data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationbar_control.rb +7 -59
  78. data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationdrawer_control.rb +0 -7
  79. data/lib/ruflet_ui/ruflet/ui/controls/materials/navigationrail_control.rb +7 -73
  80. data/lib/ruflet_ui/ruflet/ui/controls/materials/outlinedbutton_control.rb +51 -2
  81. data/lib/ruflet_ui/ruflet/ui/controls/materials/outlinediconbutton_control.rb +67 -5
  82. data/lib/ruflet_ui/ruflet/ui/controls/materials/popupmenubutton_control.rb +8 -61
  83. data/lib/ruflet_ui/ruflet/ui/controls/materials/popupmenuitem_control.rb +0 -6
  84. data/lib/ruflet_ui/ruflet/ui/controls/materials/progressbar_control.rb +8 -56
  85. data/lib/ruflet_ui/ruflet/ui/controls/materials/progressring_control.rb +8 -56
  86. data/lib/ruflet_ui/ruflet/ui/controls/materials/radio_control.rb +9 -54
  87. data/lib/ruflet_ui/ruflet/ui/controls/materials/rangeslider_control.rb +7 -62
  88. data/lib/ruflet_ui/ruflet/ui/controls/materials/reorderablelistview_control.rb +9 -64
  89. data/lib/ruflet_ui/ruflet/ui/controls/materials/ruflet_controls.rb +5 -26
  90. data/lib/ruflet_ui/ruflet/ui/controls/materials/searchbar_control.rb +80 -11
  91. data/lib/ruflet_ui/ruflet/ui/controls/materials/segment_control.rb +0 -3
  92. data/lib/ruflet_ui/ruflet/ui/controls/materials/segmentedbutton_control.rb +7 -64
  93. data/lib/ruflet_ui/ruflet/ui/controls/materials/selectionarea_control.rb +1 -3
  94. data/lib/ruflet_ui/ruflet/ui/controls/materials/slider_control.rb +9 -60
  95. data/lib/ruflet_ui/ruflet/ui/controls/materials/snackbar_control.rb +37 -4
  96. data/lib/ruflet_ui/ruflet/ui/controls/materials/snackbaraction_control.rb +38 -0
  97. data/lib/ruflet_ui/ruflet/ui/controls/materials/spinkit_control.rb +25 -0
  98. data/lib/ruflet_ui/ruflet/ui/controls/materials/submenubutton_control.rb +52 -7
  99. data/lib/ruflet_ui/ruflet/ui/controls/materials/switch_control.rb +9 -61
  100. data/lib/ruflet_ui/ruflet/ui/controls/materials/tab_control.rb +0 -7
  101. data/lib/ruflet_ui/ruflet/ui/controls/materials/tabbar_control.rb +8 -64
  102. data/lib/ruflet_ui/ruflet/ui/controls/materials/tabbarview_control.rb +43 -5
  103. data/lib/ruflet_ui/ruflet/ui/controls/materials/tabs_control.rb +7 -47
  104. data/lib/ruflet_ui/ruflet/ui/controls/materials/textbutton_control.rb +51 -2
  105. data/lib/ruflet_ui/ruflet/ui/controls/materials/textfield_control.rb +9 -132
  106. data/lib/ruflet_ui/ruflet/ui/controls/materials/timepicker_control.rb +10 -34
  107. data/lib/ruflet_ui/ruflet/ui/controls/materials/verticaldivider_control.rb +0 -9
  108. data/lib/ruflet_ui/ruflet/ui/controls/materials/video_control.rb +9 -42
  109. data/lib/ruflet_ui/ruflet/ui/controls/materials/webview_control.rb +1 -114
  110. data/lib/ruflet_ui/ruflet/ui/controls/ruflet_controls.rb +13 -28
  111. data/lib/ruflet_ui/ruflet/ui/controls/shared/animatedswitcher_control.rb +46 -4
  112. data/lib/ruflet_ui/ruflet/ui/controls/shared/arc_control.rb +1 -0
  113. data/lib/ruflet_ui/ruflet/ui/controls/shared/browsercontextmenu_control.rb +1 -12
  114. data/lib/ruflet_ui/ruflet/ui/controls/shared/canvas_control.rb +8 -54
  115. data/lib/ruflet_ui/ruflet/ui/controls/shared/circle_control.rb +1 -0
  116. data/lib/ruflet_ui/ruflet/ui/controls/shared/column_control.rb +9 -51
  117. data/lib/ruflet_ui/ruflet/ui/controls/shared/dismissible_control.rb +52 -12
  118. data/lib/ruflet_ui/ruflet/ui/controls/shared/draggable_control.rb +1 -7
  119. data/lib/ruflet_ui/ruflet/ui/controls/shared/dragtarget_control.rb +1 -3
  120. data/lib/ruflet_ui/ruflet/ui/controls/shared/fletapp_control.rb +9 -46
  121. data/lib/ruflet_ui/ruflet/ui/controls/shared/gesturedetector_control.rb +9 -113
  122. data/lib/ruflet_ui/ruflet/ui/controls/shared/gridview_control.rb +57 -13
  123. data/lib/ruflet_ui/ruflet/ui/controls/shared/hero_control.rb +9 -40
  124. data/lib/ruflet_ui/ruflet/ui/controls/shared/icon_control.rb +9 -48
  125. data/lib/ruflet_ui/ruflet/ui/controls/shared/interactiveviewer_control.rb +9 -53
  126. data/lib/ruflet_ui/ruflet/ui/controls/shared/line_control.rb +1 -0
  127. data/lib/ruflet_ui/ruflet/ui/controls/shared/listview_control.rb +57 -11
  128. data/lib/ruflet_ui/ruflet/ui/controls/shared/markdown_control.rb +9 -54
  129. data/lib/ruflet_ui/ruflet/ui/controls/shared/oval_control.rb +1 -0
  130. data/lib/ruflet_ui/ruflet/ui/controls/shared/page_control.rb +9 -58
  131. data/lib/ruflet_ui/ruflet/ui/controls/shared/pagelet_control.rb +9 -48
  132. data/lib/ruflet_ui/ruflet/ui/controls/shared/pageview_control.rb +50 -4
  133. data/lib/ruflet_ui/ruflet/ui/controls/shared/path_control.rb +1 -0
  134. data/lib/ruflet_ui/ruflet/ui/controls/shared/placeholder_control.rb +44 -9
  135. data/lib/ruflet_ui/ruflet/ui/controls/shared/points_control.rb +1 -0
  136. data/lib/ruflet_ui/ruflet/ui/controls/shared/rect_control.rb +1 -0
  137. data/lib/ruflet_ui/ruflet/ui/controls/shared/reorderabledraghandle_control.rb +43 -4
  138. data/lib/ruflet_ui/ruflet/ui/controls/shared/responsiverow_control.rb +47 -15
  139. data/lib/ruflet_ui/ruflet/ui/controls/shared/rotatedbox_control.rb +97 -0
  140. data/lib/ruflet_ui/ruflet/ui/controls/shared/row_control.rb +9 -51
  141. data/lib/ruflet_ui/ruflet/ui/controls/shared/ruflet_controls.rb +5 -0
  142. data/lib/ruflet_ui/ruflet/ui/controls/shared/safearea_control.rb +48 -4
  143. data/lib/ruflet_ui/ruflet/ui/{services/ruflet → controls/shared}/screenshot_control.rb +18 -2
  144. data/lib/ruflet_ui/ruflet/ui/controls/shared/semantics_control.rb +65 -1
  145. data/lib/ruflet_ui/ruflet/ui/controls/shared/shadermask_control.rb +9 -41
  146. data/lib/ruflet_ui/ruflet/ui/controls/shared/shimmer_control.rb +9 -44
  147. data/lib/ruflet_ui/ruflet/ui/controls/shared/stack_control.rb +44 -1
  148. data/lib/ruflet_ui/ruflet/ui/controls/shared/text_control.rb +9 -35
  149. data/lib/ruflet_ui/ruflet/ui/controls/shared/transparentpointer_control.rb +9 -38
  150. data/lib/ruflet_ui/ruflet/ui/controls/shared/view_control.rb +63 -1
  151. data/lib/ruflet_ui/ruflet/ui/controls/shared/window_control.rb +40 -66
  152. data/lib/ruflet_ui/ruflet/ui/controls/shared/windowdragarea_control.rb +45 -4
  153. data/lib/ruflet_ui/ruflet/ui/material_control_methods.rb +61 -17
  154. data/lib/ruflet_ui/ruflet/ui/material_control_registry.rb +22 -0
  155. data/lib/ruflet_ui/ruflet/ui/services/ruflet/accelerometer_control.rb +1 -0
  156. data/lib/ruflet_ui/ruflet/ui/services/ruflet/audio_recorder_control.rb +14 -36
  157. data/lib/ruflet_ui/ruflet/ui/services/ruflet/barometer_control.rb +1 -0
  158. data/lib/ruflet_ui/ruflet/ui/services/ruflet/battery_control.rb +1 -0
  159. data/lib/ruflet_ui/ruflet/ui/services/ruflet/camera_control.rb +9 -42
  160. data/lib/ruflet_ui/ruflet/ui/services/ruflet/clipboard_control.rb +31 -0
  161. data/lib/ruflet_ui/ruflet/ui/services/ruflet/connectivity_control.rb +1 -0
  162. data/lib/ruflet_ui/ruflet/ui/services/ruflet/filepicker_control.rb +1 -0
  163. data/lib/ruflet_ui/ruflet/ui/services/ruflet/flashlight_control.rb +1 -0
  164. data/lib/ruflet_ui/ruflet/ui/services/ruflet/geolocator_control.rb +14 -30
  165. data/lib/ruflet_ui/ruflet/ui/services/ruflet/gyroscope_control.rb +1 -0
  166. data/lib/ruflet_ui/ruflet/ui/services/ruflet/hapticfeedback_control.rb +1 -0
  167. data/lib/ruflet_ui/ruflet/ui/services/ruflet/magnetometer_control.rb +1 -0
  168. data/lib/ruflet_ui/ruflet/ui/services/ruflet/permissionhandler_control.rb +5 -20
  169. data/lib/ruflet_ui/ruflet/ui/services/ruflet/screenbrightness_control.rb +1 -0
  170. data/lib/ruflet_ui/ruflet/ui/services/ruflet/securestorage_control.rb +22 -49
  171. data/lib/ruflet_ui/ruflet/ui/services/ruflet/semanticsservice_control.rb +20 -15
  172. data/lib/ruflet_ui/ruflet/ui/services/ruflet/shakedetector_control.rb +1 -0
  173. data/lib/ruflet_ui/ruflet/ui/services/ruflet/share_control.rb +1 -0
  174. data/lib/ruflet_ui/ruflet/ui/services/ruflet/sharedpreferences_control.rb +1 -0
  175. data/lib/ruflet_ui/ruflet/ui/services/ruflet/storagepaths_control.rb +1 -0
  176. data/lib/ruflet_ui/ruflet/ui/services/ruflet/urllauncher_control.rb +1 -0
  177. data/lib/ruflet_ui/ruflet/ui/services/ruflet/useraccelerometer_control.rb +1 -0
  178. data/lib/ruflet_ui/ruflet/ui/services/ruflet/wakelock_control.rb +1 -0
  179. data/lib/ruflet_ui/ruflet/ui/services/ruflet_services.rb +0 -7
  180. data/lib/ruflet_ui/ruflet/ui/shared_control_forwarders.rb +20 -1
  181. data/lib/ruflet_ui.rb +12 -10
  182. metadata +7 -8
  183. data/lib/ruflet_ui/ruflet/types/animation.rb +0 -110
  184. data/lib/ruflet_ui/ruflet/ui/controls/materials/codeeditor_control.rb +0 -93
  185. data/lib/ruflet_ui/ruflet/ui/controls/materials/map_controls.rb +0 -311
  186. data/lib/ruflet_ui/ruflet/ui/controls/materials/rive_control.rb +0 -87
  187. data/lib/ruflet_ui/ruflet/ui/controls/materials/spinkit_controls.rb +0 -109
  188. data/lib/ruflet_ui/ruflet/ui/services/ruflet/tester_control.rb +0 -126
@@ -7,6 +7,7 @@ module Ruflet
7
7
  class SecureStorageControl < Ruflet::Control
8
8
  TYPE = "securestorage".freeze
9
9
  WIRE = "SecureStorage".freeze
10
+ KEYWORDS = [:android_options, :data, :ios_options, :key, :macos_options, :web_options, :windows_options, :on_change].freeze
10
11
  OPTION_KEYS = %w[web ios macos android windows].freeze
11
12
 
12
13
  def initialize(id: nil, android_options: nil, data: nil, ios_options: nil, key: nil, macos_options: nil, web_options: nil, windows_options: nil, on_change: nil)
@@ -22,66 +23,38 @@ module Ruflet
22
23
  super(type: TYPE, id: id, **props)
23
24
  end
24
25
 
25
- def set(key, value, **options)
26
- raise ArgumentError, "value must not be nil" if value.nil?
27
-
28
- invoke_secure_storage("set", args: option_args(options).merge("key" => key, "value" => value), **invoke_options(options))
29
- end
30
-
31
- def get(key, **options)
32
- invoke_secure_storage("get", args: option_args(options).merge("key" => key), **invoke_options(options))
33
- end
34
-
35
- def contains_key(key, **options)
36
- invoke_secure_storage("contains_key", args: option_args(options).merge("key" => key), **invoke_options(options))
37
- end
38
-
39
- def get_all(**options)
40
- invoke_secure_storage("get_all", args: option_args(options), **invoke_options(options))
41
- end
42
-
43
- def remove(key, **options)
44
- invoke_secure_storage("remove", args: option_args(options).merge("key" => key), **invoke_options(options))
45
- end
46
-
47
- def clear(**options)
48
- invoke_secure_storage("clear", args: option_args(options), **invoke_options(options))
49
- end
26
+ def set(key, value, **options) = invoke_with_options("set", options, "key" => key, "value" => value)
27
+ def get(key, **options) = invoke_with_options("get", options, "key" => key)
28
+ def contains_key(key, **options) = invoke_with_options("contains_key", options, "key" => key)
29
+ def get_all(**options) = invoke_with_options("get_all", options)
30
+ def remove(key, **options) = invoke_with_options("remove", options, "key" => key)
31
+ def clear(**options) = invoke_with_options("clear", options)
50
32
 
51
33
  def get_availability(timeout: 10, on_result: nil)
52
- invoke_secure_storage("get_availability", timeout: timeout, on_result: on_result)
34
+ runtime_page&.invoke(self, "get_availability", timeout: timeout, on_result: on_result)
53
35
  end
54
36
 
55
37
  private
56
38
 
57
- def invoke_secure_storage(method_name, args: nil, timeout:, on_result:)
58
- runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
59
- end
60
-
61
- def invoke_options(options)
62
- {
63
- timeout: options.fetch(:timeout, 10),
64
- on_result: options[:on_result]
65
- }
66
- end
67
-
68
- def option_args(options)
69
- OPTION_KEYS.each_with_object({}) do |key, result|
39
+ def invoke_with_options(method_name, options, args = {})
40
+ OPTION_KEYS.each do |key|
70
41
  value = options[key.to_sym] || options[key]
71
- result[key] = normalize_service_value(value) unless value.nil?
42
+ args[key] = normalize_value(value) unless value.nil?
72
43
  end
44
+ runtime_page&.invoke(
45
+ self,
46
+ method_name,
47
+ args: args,
48
+ timeout: options.fetch(:timeout, 10),
49
+ on_result: options[:on_result]
50
+ )
73
51
  end
74
52
 
75
- def normalize_service_value(value)
53
+ def normalize_value(value)
76
54
  case value
77
- when Array
78
- value.map { |item| normalize_service_value(item) }
79
- when Hash
80
- value.transform_keys(&:to_s).each_with_object({}) do |(key, item), result|
81
- result[key] = normalize_service_value(item) unless item.nil?
82
- end
83
- else
84
- value.respond_to?(:to_h) ? normalize_service_value(value.to_h) : value
55
+ when Array then value.map { |item| normalize_value(item) }
56
+ when Hash then value.each_with_object({}) { |(key, item), result| result[key.to_s] = normalize_value(item) unless item.nil? }
57
+ else value.respond_to?(:to_h) ? normalize_value(value.to_h) : value
85
58
  end
86
59
  end
87
60
  end
@@ -7,6 +7,7 @@ module Ruflet
7
7
  class SemanticsServiceControl < Ruflet::Control
8
8
  TYPE = "semanticsservice".freeze
9
9
  WIRE = "SemanticsService".freeze
10
+ KEYWORDS = [:data, :key].freeze
10
11
 
11
12
  def initialize(id: nil, data: nil, key: nil)
12
13
  props = {}
@@ -15,32 +16,36 @@ module Ruflet
15
16
  super(type: TYPE, id: id, **props)
16
17
  end
17
18
 
18
- def announce_message(message, rtl: false, assertiveness: "polite", timeout: 10, on_result: nil)
19
- runtime_page&.invoke(
20
- self,
21
- "announce_message",
22
- args: {
23
- "message" => message,
24
- "rtl" => rtl,
25
- "assertiveness" => assertiveness
26
- },
19
+ def announce_tooltip(message, timeout: 10, on_result: nil)
20
+ invoke_service(
21
+ "announce_tooltip",
22
+ args: { "message" => message.to_s },
27
23
  timeout: timeout,
28
24
  on_result: on_result
29
25
  )
30
26
  end
31
27
 
32
- def announce_tooltip(message, timeout: 10, on_result: nil)
33
- runtime_page&.invoke(
34
- self,
35
- "announce_tooltip",
36
- args: { "message" => message },
28
+ def announce_message(message, rtl: false, assertiveness: "polite", timeout: 10, on_result: nil)
29
+ invoke_service(
30
+ "announce_message",
31
+ args: {
32
+ "message" => message.to_s,
33
+ "rtl" => !!rtl,
34
+ "assertiveness" => assertiveness.to_s
35
+ },
37
36
  timeout: timeout,
38
37
  on_result: on_result
39
38
  )
40
39
  end
41
40
 
42
41
  def get_accessibility_features(timeout: 10, on_result: nil)
43
- runtime_page&.invoke(self, "get_accessibility_features", timeout: timeout, on_result: on_result)
42
+ invoke_service("get_accessibility_features", timeout: timeout, on_result: on_result)
43
+ end
44
+
45
+ private
46
+
47
+ def invoke_service(method_name, args: nil, timeout:, on_result:)
48
+ runtime_page&.invoke(self, method_name, args: args, timeout: timeout, on_result: on_result)
44
49
  end
45
50
  end
46
51
  end
@@ -7,6 +7,7 @@ module Ruflet
7
7
  class ShakeDetectorControl < Ruflet::Control
8
8
  TYPE = "shakedetector".freeze
9
9
  WIRE = "ShakeDetector".freeze
10
+ KEYWORDS = [:data, :key, :minimum_shake_count, :shake_count_reset_time_ms, :shake_slop_time_ms, :shake_threshold_gravity, :on_shake].freeze
10
11
 
11
12
  def initialize(id: nil, data: nil, key: nil, minimum_shake_count: nil, shake_count_reset_time_ms: nil, shake_slop_time_ms: nil, shake_threshold_gravity: nil, on_shake: nil)
12
13
  props = {}
@@ -7,6 +7,7 @@ module Ruflet
7
7
  class ShareControl < Ruflet::Control
8
8
  TYPE = "share".freeze
9
9
  WIRE = "Share".freeze
10
+ KEYWORDS = [:data, :key].freeze
10
11
 
11
12
  def initialize(id: nil, data: nil, key: nil)
12
13
  props = {}
@@ -7,6 +7,7 @@ module Ruflet
7
7
  class SharedPreferencesControl < Ruflet::Control
8
8
  TYPE = "sharedpreferences".freeze
9
9
  WIRE = "SharedPreferences".freeze
10
+ KEYWORDS = [:data, :key].freeze
10
11
 
11
12
  def initialize(id: nil, data: nil, key: nil)
12
13
  props = {}
@@ -7,6 +7,7 @@ module Ruflet
7
7
  class StoragePathsControl < Ruflet::Control
8
8
  TYPE = "storagepaths".freeze
9
9
  WIRE = "StoragePaths".freeze
10
+ KEYWORDS = [:data, :key].freeze
10
11
 
11
12
  def initialize(id: nil, data: nil, key: nil)
12
13
  props = {}
@@ -7,6 +7,7 @@ module Ruflet
7
7
  class UrlLauncherControl < Ruflet::Control
8
8
  TYPE = "urllauncher".freeze
9
9
  WIRE = "UrlLauncher".freeze
10
+ KEYWORDS = [:data, :key].freeze
10
11
 
11
12
  def initialize(id: nil, data: nil, key: nil)
12
13
  props = {}
@@ -7,6 +7,7 @@ module Ruflet
7
7
  class UserAccelerometerControl < Ruflet::Control
8
8
  TYPE = "useraccelerometer".freeze
9
9
  WIRE = "UserAccelerometer".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 WakelockControl < Ruflet::Control
8
8
  TYPE = "wakelock".freeze
9
9
  WIRE = "Wakelock".freeze
10
+ KEYWORDS = [:data, :key].freeze
10
11
 
11
12
  def initialize(id: nil, data: nil, key: nil)
12
13
  props = {}
@@ -15,14 +15,12 @@ require_relative "ruflet/hapticfeedback_control"
15
15
  require_relative "ruflet/magnetometer_control"
16
16
  require_relative "ruflet/permissionhandler_control"
17
17
  require_relative "ruflet/screenbrightness_control"
18
- require_relative "ruflet/screenshot_control"
19
18
  require_relative "ruflet/securestorage_control"
20
19
  require_relative "ruflet/semanticsservice_control"
21
20
  require_relative "ruflet/shakedetector_control"
22
21
  require_relative "ruflet/share_control"
23
22
  require_relative "ruflet/sharedpreferences_control"
24
23
  require_relative "ruflet/storagepaths_control"
25
- require_relative "ruflet/tester_control"
26
24
  require_relative "ruflet/urllauncher_control"
27
25
  require_relative "ruflet/useraccelerometer_control"
28
26
  require_relative "ruflet/wakelock_control"
@@ -39,8 +37,6 @@ module Ruflet
39
37
  "audiorecorder" => RufletServicesComponents::AudioRecorderControl,
40
38
  "barometer" => RufletServicesComponents::BarometerControl,
41
39
  "battery" => RufletServicesComponents::BatteryControl,
42
- "browser_context_menu" => Ruflet::UI::Controls::RufletComponents::BrowserContextMenuControl,
43
- "browsercontextmenu" => Ruflet::UI::Controls::RufletComponents::BrowserContextMenuControl,
44
40
  "camera" => RufletServicesComponents::CameraControl,
45
41
  "clipboard" => RufletServicesComponents::ClipboardControl,
46
42
  "connectivity" => RufletServicesComponents::ConnectivityControl,
@@ -56,7 +52,6 @@ module Ruflet
56
52
  "permissionhandler" => RufletServicesComponents::PermissionHandlerControl,
57
53
  "screen_brightness" => RufletServicesComponents::ScreenBrightnessControl,
58
54
  "screenbrightness" => RufletServicesComponents::ScreenBrightnessControl,
59
- "screenshot" => RufletServicesComponents::ScreenshotControl,
60
55
  "secure_storage" => RufletServicesComponents::SecureStorageControl,
61
56
  "securestorage" => RufletServicesComponents::SecureStorageControl,
62
57
  "semantics_service" => RufletServicesComponents::SemanticsServiceControl,
@@ -68,13 +63,11 @@ module Ruflet
68
63
  "sharedpreferences" => RufletServicesComponents::SharedPreferencesControl,
69
64
  "storage_paths" => RufletServicesComponents::StoragePathsControl,
70
65
  "storagepaths" => RufletServicesComponents::StoragePathsControl,
71
- "tester" => RufletServicesComponents::TesterControl,
72
66
  "url_launcher" => RufletServicesComponents::UrlLauncherControl,
73
67
  "urllauncher" => RufletServicesComponents::UrlLauncherControl,
74
68
  "user_accelerometer" => RufletServicesComponents::UserAccelerometerControl,
75
69
  "useraccelerometer" => RufletServicesComponents::UserAccelerometerControl,
76
70
  "wakelock" => RufletServicesComponents::WakelockControl,
77
- "window" => Ruflet::UI::Controls::RufletComponents::WindowControl,
78
71
  }.freeze
79
72
  end
80
73
  end
@@ -134,6 +134,7 @@ module Ruflet
134
134
  def pageview(children = nil, **props) = control_delegate.pageview(children, **props)
135
135
  def progress_ring(**props) = control_delegate.progress_ring(**props)
136
136
  def progressring(**props) = control_delegate.progressring(**props)
137
+ def spinkit(**props) = control_delegate.spinkit(**props)
137
138
  def range_slider(**props) = control_delegate.range_slider(**props)
138
139
  def rangeslider(**props) = control_delegate.rangeslider(**props)
139
140
  def responsive_row(children = nil, **props, &block) = control_delegate.responsive_row(children, **props, &block)
@@ -191,6 +192,9 @@ module Ruflet
191
192
  def slider(**props) = control_delegate.slider(**props)
192
193
  def transparent_pointer(content = nil, **props) = control_delegate.transparent_pointer(content, **props)
193
194
  def transparentpointer(content = nil, **props) = control_delegate.transparentpointer(content, **props)
195
+ def rotated_box(content = nil, **props) = control_delegate.rotated_box(content, **props)
196
+ def rotatedbox(content = nil, **props) = control_delegate.rotatedbox(content, **props)
197
+ def screenshot(content = nil, **props) = control_delegate.screenshot(content, **props)
194
198
  def radio(**props) = control_delegate.radio(**props)
195
199
  def radio_group(content = nil, **props) = control_delegate.radio_group(content, **props)
196
200
  def radiogroup(content = nil, **props) = control_delegate.radiogroup(content, **props)
@@ -198,6 +202,8 @@ module Ruflet
198
202
  def alertdialog(**props) = control_delegate.alertdialog(**props)
199
203
  def snack_bar(content = nil, **props) = control_delegate.snack_bar(content, **props)
200
204
  def snackbar(content = nil, **props) = control_delegate.snackbar(content, **props)
205
+ def snack_bar_action(label = nil, **props) = control_delegate.snack_bar_action(label, **props)
206
+ def snackbaraction(label = nil, **props) = control_delegate.snackbaraction(label, **props)
201
207
  def bottom_sheet(content = nil, **props) = control_delegate.bottom_sheet(content, **props)
202
208
  def bottomsheet(content = nil, **props) = control_delegate.bottomsheet(content, **props)
203
209
  def markdown(value = nil, **props) = control_delegate.markdown(value, **props)
@@ -270,7 +276,6 @@ module Ruflet
270
276
  def web_view(**props) = control_delegate.web_view(**props)
271
277
  def webview(**props) = control_delegate.webview(**props)
272
278
  def video(**props) = control_delegate.video(**props)
273
- def spinkit(**variant) = control_delegate.spinkit(**variant)
274
279
  def code_editor(value = nil, **props) = control_delegate.code_editor(value, **props)
275
280
  def codeeditor(value = nil, **props) = control_delegate.codeeditor(value, **props)
276
281
  def rive(src = nil, **props) = control_delegate.rive(src, **props)
@@ -324,6 +329,20 @@ module Ruflet
324
329
  def cupertinoslidingsegmentedbutton(children = nil, **props) = control_delegate.cupertinoslidingsegmentedbutton(children, **props)
325
330
  def duration(**parts) = control_delegate.duration(**parts)
326
331
 
332
+ # Client extensions are open-ended and cannot all be generated into this
333
+ # module. Unknown widget-style helpers with properties are forwarded as
334
+ # generic controls, allowing locally installed extensions to participate
335
+ # in the same Ruby DSL without VM or application-specific methods.
336
+ def method_missing(name, *args, **props, &block)
337
+ return super if name.to_s.end_with?("=") || (args.empty? && props.empty? && !block)
338
+
339
+ forwarded = props.dup
340
+ forwarded[:value] = args.shift unless args.empty?
341
+ return super unless args.empty?
342
+
343
+ control_delegate.control(name.to_s, **forwarded, &block)
344
+ end
345
+
327
346
  private
328
347
 
329
348
  def control_delegate
data/lib/ruflet_ui.rb CHANGED
@@ -5,7 +5,6 @@ require_relative "ruflet_ui/ruflet/colors"
5
5
  require_relative "ruflet_ui/ruflet/icon_data"
6
6
  require_relative "ruflet_ui/ruflet/icons/material/material_icons"
7
7
  require_relative "ruflet_ui/ruflet/icons/cupertino/cupertino_icons"
8
- require_relative "ruflet_ui/ruflet/types/animation"
9
8
  require_relative "ruflet_ui/ruflet/types/text_style"
10
9
  require_relative "ruflet_ui/ruflet/types/geometry"
11
10
  require_relative "ruflet_ui/ruflet/control"
@@ -27,9 +26,6 @@ module Ruflet
27
26
  TextDecorationStyle = UI::Types::TextDecorationStyle
28
27
  Offset = UI::Types::Offset
29
28
  Duration = UI::Types::Duration
30
- Animation = UI::Types::Animation
31
- AnimationStyle = UI::Types::AnimationStyle
32
- AnimationCurve = UI::Types::AnimationCurve
33
29
 
34
30
  module MainAxisAlignment
35
31
  CENTER = "center"
@@ -140,7 +136,7 @@ module Ruflet
140
136
  private
141
137
 
142
138
  def control_delegate
143
- Ruflet::WidgetBuilder.new
139
+ Ruflet::DSL
144
140
  end
145
141
  end
146
142
  end
@@ -154,12 +150,18 @@ module Kernel
154
150
  def app(**opts, &block) = Ruflet::DSL.app(**opts, &block)
155
151
  def page(**props, &block) = Ruflet::DSL.page(**props, &block)
156
152
 
157
- # Bare widget helpers (view, text, container, …) build real controls anywhere
158
- # — top-level scripts and Ruflet.run blocks — with no builder to instantiate.
159
- # The framework owns this plumbing so dev code stays free of it; a fresh
160
- # builder per call keeps the helpers stateless.
161
153
  def control_delegate
162
- Ruflet::WidgetBuilder.new
154
+ Ruflet::DSL
155
+ end
156
+
157
+ def method_missing(name, *args, **props, &block)
158
+ return super if name.to_s.end_with?("=") || (args.empty? && props.empty? && !block)
159
+
160
+ forwarded = props.dup
161
+ forwarded[:value] = args.shift unless args.empty?
162
+ return super unless args.empty?
163
+
164
+ Ruflet::DSL.control(name.to_s, **forwarded, &block)
163
165
  end
164
166
 
165
167
  if Ruflet::UI::SharedControlForwarders.respond_to?(:instance_methods)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruflet_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - AdamMusa
@@ -33,11 +33,11 @@ files:
33
33
  - lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.json
34
34
  - lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb
35
35
  - lib/ruflet_ui/ruflet/icons/cupertino_icon_lookup.rb
36
+ - lib/ruflet_ui/ruflet/icons/icon_constant_names.rb
36
37
  - lib/ruflet_ui/ruflet/icons/material/icons.json
37
38
  - lib/ruflet_ui/ruflet/icons/material/material_icons.rb
38
39
  - lib/ruflet_ui/ruflet/icons/material_icon_lookup.rb
39
40
  - lib/ruflet_ui/ruflet/page.rb
40
- - lib/ruflet_ui/ruflet/types/animation.rb
41
41
  - lib/ruflet_ui/ruflet/types/geometry.rb
42
42
  - lib/ruflet_ui/ruflet/types/text_style.rb
43
43
  - lib/ruflet_ui/ruflet/ui/control_factory.rb
@@ -83,7 +83,6 @@ files:
83
83
  - lib/ruflet_ui/ruflet/ui/controls/materials/checkbox_control.rb
84
84
  - lib/ruflet_ui/ruflet/ui/controls/materials/chip_control.rb
85
85
  - lib/ruflet_ui/ruflet/ui/controls/materials/circleavatar_control.rb
86
- - lib/ruflet_ui/ruflet/ui/controls/materials/codeeditor_control.rb
87
86
  - lib/ruflet_ui/ruflet/ui/controls/materials/container_control.rb
88
87
  - lib/ruflet_ui/ruflet/ui/controls/materials/contextmenu_control.rb
89
88
  - lib/ruflet_ui/ruflet/ui/controls/materials/datacell_control.rb
@@ -106,7 +105,7 @@ files:
106
105
  - lib/ruflet_ui/ruflet/ui/controls/materials/floatingactionbutton_control.rb
107
106
  - lib/ruflet_ui/ruflet/ui/controls/materials/iconbutton_control.rb
108
107
  - lib/ruflet_ui/ruflet/ui/controls/materials/listtile_control.rb
109
- - lib/ruflet_ui/ruflet/ui/controls/materials/map_controls.rb
108
+ - lib/ruflet_ui/ruflet/ui/controls/materials/map_control.rb
110
109
  - lib/ruflet_ui/ruflet/ui/controls/materials/menubar_control.rb
111
110
  - lib/ruflet_ui/ruflet/ui/controls/materials/menuitembutton_control.rb
112
111
  - lib/ruflet_ui/ruflet/ui/controls/materials/navigationbar_control.rb
@@ -126,7 +125,6 @@ files:
126
125
  - lib/ruflet_ui/ruflet/ui/controls/materials/radiogroup_control.rb
127
126
  - lib/ruflet_ui/ruflet/ui/controls/materials/rangeslider_control.rb
128
127
  - lib/ruflet_ui/ruflet/ui/controls/materials/reorderablelistview_control.rb
129
- - lib/ruflet_ui/ruflet/ui/controls/materials/rive_control.rb
130
128
  - lib/ruflet_ui/ruflet/ui/controls/materials/ruflet_controls.rb
131
129
  - lib/ruflet_ui/ruflet/ui/controls/materials/searchbar_control.rb
132
130
  - lib/ruflet_ui/ruflet/ui/controls/materials/segment_control.rb
@@ -134,7 +132,8 @@ files:
134
132
  - lib/ruflet_ui/ruflet/ui/controls/materials/selectionarea_control.rb
135
133
  - lib/ruflet_ui/ruflet/ui/controls/materials/slider_control.rb
136
134
  - lib/ruflet_ui/ruflet/ui/controls/materials/snackbar_control.rb
137
- - lib/ruflet_ui/ruflet/ui/controls/materials/spinkit_controls.rb
135
+ - lib/ruflet_ui/ruflet/ui/controls/materials/snackbaraction_control.rb
136
+ - lib/ruflet_ui/ruflet/ui/controls/materials/spinkit_control.rb
138
137
  - lib/ruflet_ui/ruflet/ui/controls/materials/submenubutton_control.rb
139
138
  - lib/ruflet_ui/ruflet/ui/controls/materials/switch_control.rb
140
139
  - lib/ruflet_ui/ruflet/ui/controls/materials/tab_control.rb
@@ -185,9 +184,11 @@ files:
185
184
  - lib/ruflet_ui/ruflet/ui/controls/shared/rect_control.rb
186
185
  - lib/ruflet_ui/ruflet/ui/controls/shared/reorderabledraghandle_control.rb
187
186
  - lib/ruflet_ui/ruflet/ui/controls/shared/responsiverow_control.rb
187
+ - lib/ruflet_ui/ruflet/ui/controls/shared/rotatedbox_control.rb
188
188
  - lib/ruflet_ui/ruflet/ui/controls/shared/row_control.rb
189
189
  - lib/ruflet_ui/ruflet/ui/controls/shared/ruflet_controls.rb
190
190
  - lib/ruflet_ui/ruflet/ui/controls/shared/safearea_control.rb
191
+ - lib/ruflet_ui/ruflet/ui/controls/shared/screenshot_control.rb
191
192
  - lib/ruflet_ui/ruflet/ui/controls/shared/semantics_control.rb
192
193
  - lib/ruflet_ui/ruflet/ui/controls/shared/serviceregistry_control.rb
193
194
  - lib/ruflet_ui/ruflet/ui/controls/shared/shadermask_control.rb
@@ -221,14 +222,12 @@ files:
221
222
  - lib/ruflet_ui/ruflet/ui/services/ruflet/magnetometer_control.rb
222
223
  - lib/ruflet_ui/ruflet/ui/services/ruflet/permissionhandler_control.rb
223
224
  - lib/ruflet_ui/ruflet/ui/services/ruflet/screenbrightness_control.rb
224
- - lib/ruflet_ui/ruflet/ui/services/ruflet/screenshot_control.rb
225
225
  - lib/ruflet_ui/ruflet/ui/services/ruflet/securestorage_control.rb
226
226
  - lib/ruflet_ui/ruflet/ui/services/ruflet/semanticsservice_control.rb
227
227
  - lib/ruflet_ui/ruflet/ui/services/ruflet/shakedetector_control.rb
228
228
  - lib/ruflet_ui/ruflet/ui/services/ruflet/share_control.rb
229
229
  - lib/ruflet_ui/ruflet/ui/services/ruflet/sharedpreferences_control.rb
230
230
  - lib/ruflet_ui/ruflet/ui/services/ruflet/storagepaths_control.rb
231
- - lib/ruflet_ui/ruflet/ui/services/ruflet/tester_control.rb
232
231
  - lib/ruflet_ui/ruflet/ui/services/ruflet/urllauncher_control.rb
233
232
  - lib/ruflet_ui/ruflet/ui/services/ruflet/useraccelerometer_control.rb
234
233
  - lib/ruflet_ui/ruflet/ui/services/ruflet/wakelock_control.rb
@@ -1,110 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module Types
6
- module AnimationCurve
7
- BOUNCE_IN = "bounceIn"
8
- BOUNCE_IN_OUT = "bounceInOut"
9
- BOUNCE_OUT = "bounceOut"
10
- DECELERATE = "decelerate"
11
- EASE = "ease"
12
- EASE_IN = "easeIn"
13
- EASE_IN_BACK = "easeInBack"
14
- EASE_IN_CIRC = "easeInCirc"
15
- EASE_IN_CUBIC = "easeInCubic"
16
- EASE_IN_EXPO = "easeInExpo"
17
- EASE_IN_OUT = "easeInOut"
18
- EASE_IN_OUT_BACK = "easeInOutBack"
19
- EASE_IN_OUT_CIRC = "easeInOutCirc"
20
- EASE_IN_OUT_CUBIC = "easeInOutCubic"
21
- EASE_IN_OUT_CUBIC_EMPHASIZED = "easeInOutCubicEmphasized"
22
- EASE_IN_OUT_EXPO = "easeInOutExpo"
23
- EASE_IN_OUT_QUAD = "easeInOutQuad"
24
- EASE_IN_OUT_QUART = "easeInOutQuart"
25
- EASE_IN_OUT_QUINT = "easeInOutQuint"
26
- EASE_IN_OUT_SINE = "easeInOutSine"
27
- EASE_IN_QUAD = "easeInQuad"
28
- EASE_IN_QUART = "easeInQuart"
29
- EASE_IN_QUINT = "easeInQuint"
30
- EASE_IN_SINE = "easeInSine"
31
- EASE_IN_TO_LINEAR = "easeInToLinear"
32
- EASE_OUT = "easeOut"
33
- EASE_OUT_BACK = "easeOutBack"
34
- EASE_OUT_CIRC = "easeOutCirc"
35
- EASE_OUT_CUBIC = "easeOutCubic"
36
- EASE_OUT_EXPO = "easeOutExpo"
37
- EASE_OUT_QUAD = "easeOutQuad"
38
- EASE_OUT_QUART = "easeOutQuart"
39
- EASE_OUT_QUINT = "easeOutQuint"
40
- EASE_OUT_SINE = "easeOutSine"
41
- ELASTIC_IN = "elasticIn"
42
- ELASTIC_IN_OUT = "elasticInOut"
43
- ELASTIC_OUT = "elasticOut"
44
- FAST_LINEAR_TO_SLOW_EASE_IN = "fastLinearToSlowEaseIn"
45
- FAST_OUT_SLOWIN = "fastOutSlowIn"
46
- LINEAR = "linear"
47
- LINEAR_TO_EASE_OUT = "linearToEaseOut"
48
- SLOW_MIDDLE = "slowMiddle"
49
-
50
- module_function
51
-
52
- def values
53
- constants(false).map { |name| const_get(name) }
54
- end
55
- end
56
-
57
- class Animation
58
- attr_reader :duration, :curve
59
-
60
- def initialize(duration: nil, curve: AnimationCurve::LINEAR)
61
- @duration = duration
62
- @curve = curve
63
- end
64
-
65
- def copy(duration: nil, curve: nil)
66
- self.class.new(
67
- duration: duration.nil? ? @duration : duration,
68
- curve: curve.nil? ? @curve : curve
69
- )
70
- end
71
-
72
- def to_h
73
- {}.tap do |hash|
74
- hash["duration"] = duration unless duration.nil?
75
- hash["curve"] = curve unless curve.nil?
76
- end
77
- end
78
- end
79
-
80
- class AnimationStyle
81
- attr_reader :duration, :reverse_duration, :curve, :reverse_curve
82
-
83
- def initialize(duration: nil, reverse_duration: nil, curve: nil, reverse_curve: nil)
84
- @duration = duration
85
- @reverse_duration = reverse_duration
86
- @curve = curve
87
- @reverse_curve = reverse_curve
88
- end
89
-
90
- def copy(duration: nil, reverse_duration: nil, curve: nil, reverse_curve: nil)
91
- self.class.new(
92
- duration: duration.nil? ? @duration : duration,
93
- reverse_duration: reverse_duration.nil? ? @reverse_duration : reverse_duration,
94
- curve: curve.nil? ? @curve : curve,
95
- reverse_curve: reverse_curve.nil? ? @reverse_curve : reverse_curve
96
- )
97
- end
98
-
99
- def to_h
100
- {}.tap do |hash|
101
- hash["duration"] = duration unless duration.nil?
102
- hash["reverse_duration"] = reverse_duration unless reverse_duration.nil?
103
- hash["curve"] = curve unless curve.nil?
104
- hash["reverse_curve"] = reverse_curve unless reverse_curve.nil?
105
- end
106
- end
107
- end
108
- end
109
- end
110
- end
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module Controls
6
- module RufletComponents
7
- # CodeEditor control — parity with Flet's CodeEditor extension
8
- # (https://flet.dev/docs/controls/codeeditor/).
9
- #
10
- # Properties: value, language, code_theme, text_style, padding, selection,
11
- # gutter_style, autocomplete, autocomplete_words, issues, read_only,
12
- # autofocus, plus the usual layout props.
13
- # Events: on_change, on_selection_change, on_focus, on_blur.
14
- # Methods (invoked over the wire on a mounted control): focus, fold_at,
15
- # fold_comment_at_line_zero, fold_imports.
16
- #
17
- # `language` accepts a highlight.js identifier (e.g. "python", "ruby",
18
- # "javascript"); `code_theme` accepts a highlight.js theme name shared
19
- # with Markdown (e.g. "atom-one-light", "atom-one-dark", "monokai-sublime").
20
- class CodeEditorControl < Ruflet::Control
21
- TYPE = "CodeEditor".freeze
22
- WIRE = "CodeEditor".freeze
23
-
24
- def initialize(id: nil, adaptive: nil, autocomplete: nil, autocomplete_words: nil,
25
- autofocus: nil, badge: nil, code_theme: nil, col: nil, data: nil,
26
- disabled: nil, expand: nil, expand_loose: nil, gutter_style: nil,
27
- height: nil, issues: nil, key: nil, language: nil, opacity: nil,
28
- padding: nil, read_only: nil, rtl: nil, selection: nil,
29
- text_style: nil, tooltip: nil, value: nil, visible: nil, width: nil,
30
- on_blur: nil, on_change: nil, on_focus: nil, on_selection_change: nil)
31
- props = {}
32
- props[:adaptive] = adaptive unless adaptive.nil?
33
- props[:autocomplete] = autocomplete unless autocomplete.nil?
34
- props[:autocomplete_words] = autocomplete_words unless autocomplete_words.nil?
35
- props[:autofocus] = autofocus unless autofocus.nil?
36
- props[:badge] = badge unless badge.nil?
37
- props[:code_theme] = code_theme unless code_theme.nil?
38
- props[:col] = col unless col.nil?
39
- props[:data] = data unless data.nil?
40
- props[:disabled] = disabled unless disabled.nil?
41
- props[:expand] = expand unless expand.nil?
42
- props[:expand_loose] = expand_loose unless expand_loose.nil?
43
- props[:gutter_style] = gutter_style unless gutter_style.nil?
44
- props[:height] = height unless height.nil?
45
- props[:issues] = issues unless issues.nil?
46
- props[:key] = key unless key.nil?
47
- props[:language] = language unless language.nil?
48
- props[:opacity] = opacity unless opacity.nil?
49
- props[:padding] = padding unless padding.nil?
50
- props[:read_only] = read_only unless read_only.nil?
51
- props[:rtl] = rtl unless rtl.nil?
52
- props[:selection] = selection unless selection.nil?
53
- props[:text_style] = text_style unless text_style.nil?
54
- props[:tooltip] = tooltip unless tooltip.nil?
55
- props[:value] = value unless value.nil?
56
- props[:visible] = visible unless visible.nil?
57
- props[:width] = width unless width.nil?
58
- props[:on_blur] = on_blur unless on_blur.nil?
59
- props[:on_change] = on_change unless on_change.nil?
60
- props[:on_focus] = on_focus unless on_focus.nil?
61
- props[:on_selection_change] = on_selection_change unless on_selection_change.nil?
62
- super(type: TYPE, id: id, **props)
63
- end
64
-
65
- # Request focus for the editor.
66
- def focus = invoke_editor_method("focus")
67
-
68
- # Fold the code block that starts at the given line number.
69
- def fold_at(line_number)
70
- invoke_editor_method("fold_at", { "line_number" => line_number.to_i })
71
- end
72
-
73
- # Fold the comment block at line 0 (e.g. a license header).
74
- def fold_comment_at_line_zero = invoke_editor_method("fold_comment_at_line_zero")
75
-
76
- # Fold all import sections.
77
- def fold_imports = invoke_editor_method("fold_imports")
78
-
79
- private
80
-
81
- def invoke_editor_method(name, args = nil, timeout: 10, on_result: nil)
82
- page = runtime_page
83
- unless page && wire_id
84
- raise "CodeEditor ##{id} is not mounted yet — add it to the page before calling #{name}."
85
- end
86
-
87
- page.invoke(self, name, args: args, timeout: timeout, on_result: on_result)
88
- end
89
- end
90
- end
91
- end
92
- end
93
- end