ruflet 0.0.7 → 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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ruflet +6 -0
  3. data/lib/ruflet/cli/build_command.rb +372 -0
  4. data/lib/ruflet/cli/extra_command.rb +146 -0
  5. data/lib/ruflet/cli/flutter_sdk.rb +359 -0
  6. data/lib/ruflet/cli/new_command.rb +221 -0
  7. data/lib/ruflet/cli/run_command.rb +699 -0
  8. data/lib/ruflet/cli/templates.rb +68 -0
  9. data/lib/ruflet/cli/update_command.rb +111 -0
  10. data/lib/ruflet/cli.rb +85 -0
  11. data/lib/ruflet/version.rb +1 -1
  12. data/lib/ruflet_cli.rb +3 -0
  13. metadata +59 -75
  14. data/lib/ruflet/manifest_compiler.rb +0 -62
  15. data/lib/ruflet.rb +0 -40
  16. data/lib/ruflet_protocol/ruflet/protocol.rb +0 -62
  17. data/lib/ruflet_protocol.rb +0 -4
  18. data/lib/ruflet_ui/ruflet/app.rb +0 -31
  19. data/lib/ruflet_ui/ruflet/colors.rb +0 -234
  20. data/lib/ruflet_ui/ruflet/control.rb +0 -168
  21. data/lib/ruflet_ui/ruflet/dsl.rb +0 -227
  22. data/lib/ruflet_ui/ruflet/event.rb +0 -28
  23. data/lib/ruflet_ui/ruflet/icon_data.rb +0 -62
  24. data/lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb +0 -54
  25. data/lib/ruflet_ui/ruflet/icons/cupertino_icon_lookup.rb +0 -112
  26. data/lib/ruflet_ui/ruflet/icons/material_icon_lookup.rb +0 -112
  27. data/lib/ruflet_ui/ruflet/icons/material_icons.rb +0 -55
  28. data/lib/ruflet_ui/ruflet/page.rb +0 -741
  29. data/lib/ruflet_ui/ruflet/ui/control_factory.rb +0 -23
  30. data/lib/ruflet_ui/ruflet/ui/control_methods.rb +0 -16
  31. data/lib/ruflet_ui/ruflet/ui/control_registry.rb +0 -13
  32. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_action_sheet_control.rb +0 -13
  33. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_alert_dialog_control.rb +0 -13
  34. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_button_control.rb +0 -13
  35. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_dialog_action_control.rb +0 -24
  36. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_filled_button_control.rb +0 -13
  37. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_navigation_bar_control.rb +0 -13
  38. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_slider_control.rb +0 -13
  39. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_switch_control.rb +0 -13
  40. data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_text_field_control.rb +0 -13
  41. data/lib/ruflet_ui/ruflet/ui/controls/material/alert_dialog_control.rb +0 -13
  42. data/lib/ruflet_ui/ruflet/ui/controls/material/app_bar_control.rb +0 -13
  43. data/lib/ruflet_ui/ruflet/ui/controls/material/bottom_sheet_control.rb +0 -13
  44. data/lib/ruflet_ui/ruflet/ui/controls/material/button_control.rb +0 -24
  45. data/lib/ruflet_ui/ruflet/ui/controls/material/checkbox_control.rb +0 -13
  46. data/lib/ruflet_ui/ruflet/ui/controls/material/column_control.rb +0 -13
  47. data/lib/ruflet_ui/ruflet/ui/controls/material/container_control.rb +0 -13
  48. data/lib/ruflet_ui/ruflet/ui/controls/material/drag_target_control.rb +0 -13
  49. data/lib/ruflet_ui/ruflet/ui/controls/material/draggable_control.rb +0 -13
  50. data/lib/ruflet_ui/ruflet/ui/controls/material/elevated_button_control.rb +0 -13
  51. data/lib/ruflet_ui/ruflet/ui/controls/material/filled_button_control.rb +0 -13
  52. data/lib/ruflet_ui/ruflet/ui/controls/material/floating_action_button_control.rb +0 -28
  53. data/lib/ruflet_ui/ruflet/ui/controls/material/gesture_detector_control.rb +0 -13
  54. data/lib/ruflet_ui/ruflet/ui/controls/material/grid_view_control.rb +0 -13
  55. data/lib/ruflet_ui/ruflet/ui/controls/material/icon_button_control.rb +0 -13
  56. data/lib/ruflet_ui/ruflet/ui/controls/material/icon_control.rb +0 -24
  57. data/lib/ruflet_ui/ruflet/ui/controls/material/image_control.rb +0 -13
  58. data/lib/ruflet_ui/ruflet/ui/controls/material/markdown_control.rb +0 -13
  59. data/lib/ruflet_ui/ruflet/ui/controls/material/navigation_bar_control.rb +0 -13
  60. data/lib/ruflet_ui/ruflet/ui/controls/material/navigation_bar_destination_control.rb +0 -13
  61. data/lib/ruflet_ui/ruflet/ui/controls/material/radio_control.rb +0 -13
  62. data/lib/ruflet_ui/ruflet/ui/controls/material/radio_group_control.rb +0 -13
  63. data/lib/ruflet_ui/ruflet/ui/controls/material/row_control.rb +0 -13
  64. data/lib/ruflet_ui/ruflet/ui/controls/material/snack_bar_control.rb +0 -68
  65. data/lib/ruflet_ui/ruflet/ui/controls/material/stack_control.rb +0 -13
  66. data/lib/ruflet_ui/ruflet/ui/controls/material/tab_bar_control.rb +0 -13
  67. data/lib/ruflet_ui/ruflet/ui/controls/material/tab_bar_view_control.rb +0 -13
  68. data/lib/ruflet_ui/ruflet/ui/controls/material/tab_control.rb +0 -13
  69. data/lib/ruflet_ui/ruflet/ui/controls/material/tabs_control.rb +0 -63
  70. data/lib/ruflet_ui/ruflet/ui/controls/material/text_button_control.rb +0 -13
  71. data/lib/ruflet_ui/ruflet/ui/controls/material/text_control.rb +0 -13
  72. data/lib/ruflet_ui/ruflet/ui/controls/material/text_field_control.rb +0 -13
  73. data/lib/ruflet_ui/ruflet/ui/controls/material/view_control.rb +0 -13
  74. data/lib/ruflet_ui/ruflet/ui/cupertino_control_factory.rb +0 -40
  75. data/lib/ruflet_ui/ruflet/ui/cupertino_control_methods.rb +0 -26
  76. data/lib/ruflet_ui/ruflet/ui/cupertino_control_registry.rb +0 -49
  77. data/lib/ruflet_ui/ruflet/ui/material_control_factory.rb +0 -97
  78. data/lib/ruflet_ui/ruflet/ui/material_control_methods.rb +0 -128
  79. data/lib/ruflet_ui/ruflet/ui/material_control_registry.rb +0 -154
  80. data/lib/ruflet_ui/ruflet/ui/shared_control_forwarders.rb +0 -89
  81. data/lib/ruflet_ui/ruflet/ui/widget_builder.rb +0 -55
  82. data/lib/ruflet_ui.rb +0 -111
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module Controls
6
- class TabBarViewControl < Ruflet::Control
7
- def initialize(id: nil, **props)
8
- super(type: "tabbarview", id: id, **props)
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module Controls
6
- class TabControl < Ruflet::Control
7
- def initialize(id: nil, **props)
8
- super(type: "tab", id: id, **props)
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "column_control"
4
- require_relative "tab_control"
5
- require_relative "tab_bar_control"
6
- require_relative "tab_bar_view_control"
7
-
8
- module Ruflet
9
- module UI
10
- module Controls
11
- class TabsControl < Ruflet::Control
12
- def initialize(id: nil, **props)
13
- super(type: "tabs", id: id, **props)
14
- end
15
-
16
- private
17
-
18
- # Normalize shorthand tabs payload into Flet's expected structure:
19
- # Tabs(length, content: Column(TabBar, TabBarView))
20
- def preprocess_props(props)
21
- mapped = props.dup
22
- tabs = mapped.delete(:tabs) || mapped.delete("tabs")
23
- return mapped if tabs.nil?
24
- return mapped unless tabs.is_a?(Array)
25
- return mapped if mapped.key?(:content) || mapped.key?("content")
26
-
27
- tab_controls = []
28
- view_controls = []
29
-
30
- tabs.each do |tab|
31
- unless tab.is_a?(Ruflet::Control) && tab.type == "tab"
32
- # Keep TabBar and TabBarView lengths aligned.
33
- tab_controls << Ruflet::UI::Controls::TabControl.new(label: tab)
34
- view_controls << Ruflet::UI::Controls::ColumnControl.new(controls: [])
35
- next
36
- end
37
-
38
- label = tab.props["label"]
39
- icon = tab.props["icon"]
40
- header_tab = Ruflet::UI::Controls::TabControl.new(label: label, icon: icon)
41
- tab_controls << header_tab
42
-
43
- content = tab.props["content"]
44
- view_controls << (content.is_a?(Ruflet::Control) ? content : Ruflet::UI::Controls::ColumnControl.new(controls: []))
45
- end
46
-
47
- tab_bar = Ruflet::UI::Controls::TabBarControl.new(tabs: tab_controls)
48
- tab_bar_view_props = { controls: view_controls }
49
- # Only opt into flexed TabBarView when developer explicitly sizes Tabs.
50
- if mapped.key?(:expand) || mapped.key?("expand") || mapped.key?(:height) || mapped.key?("height")
51
- tab_bar_view_props[:expand] = 1
52
- end
53
- tab_bar_view = Ruflet::UI::Controls::TabBarViewControl.new(**tab_bar_view_props)
54
- content = Ruflet::UI::Controls::ColumnControl.new(expand: true, spacing: 0, controls: [tab_bar, tab_bar_view])
55
-
56
- mapped[:length] = tab_controls.length unless mapped.key?(:length) || mapped.key?("length")
57
- mapped[:content] = content
58
- mapped
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module Controls
6
- class TextButtonControl < ButtonControl
7
- def initialize(id: nil, **props)
8
- super(type: "textbutton", id: id, **props)
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module Controls
6
- class TextControl < Ruflet::Control
7
- def initialize(id: nil, **props)
8
- super(type: "text", id: id, **props)
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module Controls
6
- class TextFieldControl < Ruflet::Control
7
- def initialize(id: nil, **props)
8
- super(type: "textfield", id: id, **props)
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module Controls
6
- class ViewControl < Ruflet::Control
7
- def initialize(id: nil, **props)
8
- super(type: "view", id: id, **props)
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "controls/cupertino/cupertino_button_control"
4
- require_relative "controls/cupertino/cupertino_filled_button_control"
5
- require_relative "controls/cupertino/cupertino_text_field_control"
6
- require_relative "controls/cupertino/cupertino_switch_control"
7
- require_relative "controls/cupertino/cupertino_slider_control"
8
- require_relative "controls/cupertino/cupertino_alert_dialog_control"
9
- require_relative "controls/cupertino/cupertino_action_sheet_control"
10
- require_relative "controls/cupertino/cupertino_dialog_action_control"
11
- require_relative "controls/cupertino/cupertino_navigation_bar_control"
12
-
13
- module Ruflet
14
- module UI
15
- module CupertinoControlFactory
16
- module_function
17
-
18
- CLASS_MAP = {
19
- "cupertino_button" => Controls::CupertinoButtonControl,
20
- "cupertinobutton" => Controls::CupertinoButtonControl,
21
- "cupertino_filled_button" => Controls::CupertinoFilledButtonControl,
22
- "cupertinofilledbutton" => Controls::CupertinoFilledButtonControl,
23
- "cupertino_text_field" => Controls::CupertinoTextFieldControl,
24
- "cupertinotextfield" => Controls::CupertinoTextFieldControl,
25
- "cupertino_switch" => Controls::CupertinoSwitchControl,
26
- "cupertinoswitch" => Controls::CupertinoSwitchControl,
27
- "cupertino_slider" => Controls::CupertinoSliderControl,
28
- "cupertinoslider" => Controls::CupertinoSliderControl,
29
- "cupertino_alert_dialog" => Controls::CupertinoAlertDialogControl,
30
- "cupertinoalertdialog" => Controls::CupertinoAlertDialogControl,
31
- "cupertino_action_sheet" => Controls::CupertinoActionSheetControl,
32
- "cupertinoactionsheet" => Controls::CupertinoActionSheetControl,
33
- "cupertino_dialog_action" => Controls::CupertinoDialogActionControl,
34
- "cupertinodialogaction" => Controls::CupertinoDialogActionControl,
35
- "cupertino_navigation_bar" => Controls::CupertinoNavigationBarControl,
36
- "cupertinonavigationbar" => Controls::CupertinoNavigationBarControl
37
- }.freeze
38
- end
39
- end
40
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module CupertinoControlMethods
6
- def cupertino_button(**props) = build_widget(:cupertino_button, **props)
7
- def cupertinobutton(**props) = cupertino_button(**props)
8
- def cupertino_filled_button(**props) = build_widget(:cupertino_filled_button, **props)
9
- def cupertinofilledbutton(**props) = cupertino_filled_button(**props)
10
- def cupertino_text_field(**props) = build_widget(:cupertino_text_field, **props)
11
- def cupertinotextfield(**props) = cupertino_text_field(**props)
12
- def cupertino_switch(**props) = build_widget(:cupertino_switch, **props)
13
- def cupertinoswitch(**props) = cupertino_switch(**props)
14
- def cupertino_slider(**props) = build_widget(:cupertino_slider, **props)
15
- def cupertinoslider(**props) = cupertino_slider(**props)
16
- def cupertino_alert_dialog(**props) = build_widget(:cupertino_alert_dialog, **props)
17
- def cupertinoalertdialog(**props) = cupertino_alert_dialog(**props)
18
- def cupertino_action_sheet(**props) = build_widget(:cupertino_action_sheet, **props)
19
- def cupertinoactionsheet(**props) = cupertino_action_sheet(**props)
20
- def cupertino_dialog_action(**props) = build_widget(:cupertino_dialog_action, **props)
21
- def cupertinodialogaction(**props) = cupertino_dialog_action(**props)
22
- def cupertino_navigation_bar(**props) = build_widget(:cupertino_navigation_bar, **props)
23
- def cupertinonavigationbar(**props) = cupertino_navigation_bar(**props)
24
- end
25
- end
26
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module CupertinoControlRegistry
6
- TYPE_MAP = {
7
- "cupertino_button" => "CupertinoButton",
8
- "cupertinobutton" => "CupertinoButton",
9
- "cupertino_filled_button" => "CupertinoFilledButton",
10
- "cupertinofilledbutton" => "CupertinoFilledButton",
11
- "cupertino_tinted_button" => "CupertinoTintedButton",
12
- "cupertinotintedbutton" => "CupertinoTintedButton",
13
- "cupertino_text_field" => "CupertinoTextField",
14
- "cupertinotextfield" => "CupertinoTextField",
15
- "cupertino_checkbox" => "CupertinoCheckbox",
16
- "cupertinocheckbox" => "CupertinoCheckbox",
17
- "cupertino_switch" => "CupertinoSwitch",
18
- "cupertinoswitch" => "CupertinoSwitch",
19
- "cupertino_slider" => "CupertinoSlider",
20
- "cupertinoslider" => "CupertinoSlider",
21
- "cupertino_radio" => "CupertinoRadio",
22
- "cupertinoradio" => "CupertinoRadio",
23
- "cupertino_alert_dialog" => "CupertinoAlertDialog",
24
- "cupertinoalertdialog" => "CupertinoAlertDialog",
25
- "cupertino_action_sheet" => "CupertinoActionSheet",
26
- "cupertinoactionsheet" => "CupertinoActionSheet",
27
- "cupertino_dialog_action" => "CupertinoDialogAction",
28
- "cupertinodialogaction" => "CupertinoDialogAction",
29
- "cupertino_bottom_sheet" => "CupertinoBottomSheet",
30
- "cupertinobottomsheet" => "CupertinoBottomSheet",
31
- "cupertino_picker" => "CupertinoPicker",
32
- "cupertinopicker" => "CupertinoPicker",
33
- "cupertino_date_picker" => "CupertinoDatePicker",
34
- "cupertinodatepicker" => "CupertinoDatePicker",
35
- "cupertino_timer_picker" => "CupertinoTimerPicker",
36
- "cupertinotimerpicker" => "CupertinoTimerPicker",
37
- "cupertino_navigation_bar" => "CupertinoNavigationBar",
38
- "cupertinonavigationbar" => "CupertinoNavigationBar"
39
- }.freeze
40
-
41
- EVENT_PROPS = {
42
- on_click: "click",
43
- on_change: "change",
44
- on_submit: "submit",
45
- on_dismiss: "dismiss"
46
- }.freeze
47
- end
48
- end
49
- end
@@ -1,97 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "controls/material/text_control"
4
- require_relative "controls/material/view_control"
5
- require_relative "controls/material/container_control"
6
- require_relative "controls/material/column_control"
7
- require_relative "controls/material/row_control"
8
- require_relative "controls/material/stack_control"
9
- require_relative "controls/material/grid_view_control"
10
- require_relative "controls/material/gesture_detector_control"
11
- require_relative "controls/material/draggable_control"
12
- require_relative "controls/material/drag_target_control"
13
- require_relative "controls/material/text_field_control"
14
- require_relative "controls/material/button_control"
15
- require_relative "controls/material/elevated_button_control"
16
- require_relative "controls/material/text_button_control"
17
- require_relative "controls/material/filled_button_control"
18
- require_relative "controls/material/icon_button_control"
19
- require_relative "controls/material/icon_control"
20
- require_relative "controls/material/image_control"
21
- require_relative "controls/material/app_bar_control"
22
- require_relative "controls/material/floating_action_button_control"
23
- require_relative "controls/material/checkbox_control"
24
- require_relative "controls/material/radio_control"
25
- require_relative "controls/material/radio_group_control"
26
- require_relative "controls/material/alert_dialog_control"
27
- require_relative "controls/material/snack_bar_control"
28
- require_relative "controls/material/bottom_sheet_control"
29
- require_relative "controls/material/markdown_control"
30
- require_relative "controls/material/tabs_control"
31
- require_relative "controls/material/tab_control"
32
- require_relative "controls/material/tab_bar_control"
33
- require_relative "controls/material/tab_bar_view_control"
34
- require_relative "controls/material/navigation_bar_control"
35
- require_relative "controls/material/navigation_bar_destination_control"
36
-
37
- module Ruflet
38
- module UI
39
- module MaterialControlFactory
40
- module_function
41
-
42
- CLASS_MAP = {
43
- "text" => Controls::TextControl,
44
- "view" => Controls::ViewControl,
45
- "column" => Controls::ColumnControl,
46
- "row" => Controls::RowControl,
47
- "stack" => Controls::StackControl,
48
- "gridview" => Controls::GridViewControl,
49
- "grid_view" => Controls::GridViewControl,
50
- "container" => Controls::ContainerControl,
51
- "gesturedetector" => Controls::GestureDetectorControl,
52
- "gesture_detector" => Controls::GestureDetectorControl,
53
- "draggable" => Controls::DraggableControl,
54
- "dragtarget" => Controls::DragTargetControl,
55
- "drag_target" => Controls::DragTargetControl,
56
- "textfield" => Controls::TextFieldControl,
57
- "text_field" => Controls::TextFieldControl,
58
- "button" => Controls::ButtonControl,
59
- "elevatedbutton" => Controls::ElevatedButtonControl,
60
- "elevated_button" => Controls::ElevatedButtonControl,
61
- "textbutton" => Controls::TextButtonControl,
62
- "text_button" => Controls::TextButtonControl,
63
- "filledbutton" => Controls::FilledButtonControl,
64
- "filled_button" => Controls::FilledButtonControl,
65
- "iconbutton" => Controls::IconButtonControl,
66
- "icon_button" => Controls::IconButtonControl,
67
- "icon" => Controls::IconControl,
68
- "image" => Controls::ImageControl,
69
- "appbar" => Controls::AppBarControl,
70
- "app_bar" => Controls::AppBarControl,
71
- "floatingactionbutton" => Controls::FloatingActionButtonControl,
72
- "floating_action_button" => Controls::FloatingActionButtonControl,
73
- "checkbox" => Controls::CheckboxControl,
74
- "radio" => Controls::RadioControl,
75
- "radiogroup" => Controls::RadioGroupControl,
76
- "radio_group" => Controls::RadioGroupControl,
77
- "alertdialog" => Controls::AlertDialogControl,
78
- "alert_dialog" => Controls::AlertDialogControl,
79
- "snackbar" => Controls::SnackBarControl,
80
- "snack_bar" => Controls::SnackBarControl,
81
- "bottomsheet" => Controls::BottomSheetControl,
82
- "bottom_sheet" => Controls::BottomSheetControl,
83
- "markdown" => Controls::MarkdownControl,
84
- "tabs" => Controls::TabsControl,
85
- "tab" => Controls::TabControl,
86
- "tabbar" => Controls::TabBarControl,
87
- "tab_bar" => Controls::TabBarControl,
88
- "tabbarview" => Controls::TabBarViewControl,
89
- "tab_bar_view" => Controls::TabBarViewControl,
90
- "navigationbar" => Controls::NavigationBarControl,
91
- "navigation_bar" => Controls::NavigationBarControl,
92
- "navigationbardestination" => Controls::NavigationBarDestinationControl,
93
- "navigation_bar_destination" => Controls::NavigationBarDestinationControl
94
- }.freeze
95
- end
96
- end
97
- end
@@ -1,128 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module MaterialControlMethods
6
- def view(**props, &block) = build_widget(:view, **props, &block)
7
- def column(**props, &block) = build_widget(:column, **props, &block)
8
-
9
- def center(**props, &block)
10
- mapped = props.dup
11
- defaults = { expand: true, alignment: { x: 0, y: 0 } }
12
-
13
- if block
14
- nested = WidgetBuilder.new
15
- block_result = nested.instance_eval(&block)
16
- child =
17
- if nested.children.any?
18
- nested.children.first
19
- elsif block_result.is_a?(Ruflet::Control)
20
- block_result
21
- end
22
- mapped[:content] = child if child
23
- end
24
-
25
- build_widget(:container, **normalize_container_props(defaults.merge(mapped)))
26
- end
27
-
28
- def row(**props, &block) = build_widget(:row, **props, &block)
29
- def stack(**props, &block) = build_widget(:stack, **props, &block)
30
- def grid_view(**props, &block) = build_widget(:gridview, **props, &block)
31
- def gridview(**props, &block) = grid_view(**props, &block)
32
- def container(**props, &block) = build_widget(:container, **normalize_container_props(props), &block)
33
- def gesture_detector(**props, &block) = build_widget(:gesturedetector, **props, &block)
34
- def gesturedetector(**props, &block) = gesture_detector(**props, &block)
35
- def draggable(**props, &block) = build_widget(:draggable, **props, &block)
36
- def drag_target(**props, &block) = build_widget(:dragtarget, **props, &block)
37
- def dragtarget(**props, &block) = drag_target(**props, &block)
38
-
39
- def text(value = nil, **props)
40
- mapped = props.dup
41
- mapped[:value] = value unless value.nil?
42
- build_widget(:text, **mapped)
43
- end
44
-
45
- def button(**props) = build_widget(:button, **props)
46
- def elevated_button(**props) = build_widget(:elevatedbutton, **props)
47
- def elevatedbutton(**props) = elevated_button(**props)
48
- def text_button(**props) = build_widget(:textbutton, **props)
49
- def textbutton(**props) = text_button(**props)
50
- def filled_button(**props) = build_widget(:filledbutton, **props)
51
- def filledbutton(**props) = filled_button(**props)
52
-
53
- def icon_button(**props) = build_widget(:iconbutton, **props)
54
- def iconbutton(**props) = icon_button(**props)
55
- def text_field(**props) = build_widget(:textfield, **props)
56
- def textfield(**props) = text_field(**props)
57
- def checkbox(**props) = build_widget(:checkbox, **props)
58
- def radio(**props) = build_widget(:radio, **props)
59
- def radio_group(**props) = build_widget(:radiogroup, **props)
60
- def radiogroup(**props) = radio_group(**props)
61
- def alert_dialog(**props) = build_widget(:alertdialog, **props)
62
- def alertdialog(**props) = alert_dialog(**props)
63
- def snack_bar(**props) = build_widget(:snackbar, **props)
64
- def snackbar(**props) = snack_bar(**props)
65
- def bottom_sheet(**props) = build_widget(:bottomsheet, **props)
66
- def bottomsheet(**props) = bottom_sheet(**props)
67
-
68
- def markdown(value = nil, **props)
69
- mapped = props.dup
70
- mapped[:value] = value unless value.nil?
71
- build_widget(:markdown, **mapped)
72
- end
73
-
74
- def icon(**props) = build_widget(:icon, **props)
75
-
76
- def image(src = nil, src_base64: nil, placeholder_src: nil, **props)
77
- mapped = props.dup
78
- mapped[:src] = normalize_image_source(src) unless src.nil?
79
- mapped[:src] = normalize_image_source(src_base64) if mapped[:src].nil? && !src_base64.nil?
80
- mapped[:placeholder_src] = normalize_image_source(placeholder_src) unless placeholder_src.nil?
81
- build_widget(:image, **mapped)
82
- end
83
-
84
- def app_bar(**props) = build_widget(:appbar, **props)
85
- def appbar(**props) = app_bar(**props)
86
- def url_launcher(**props) = build_widget(:url_launcher, **props)
87
- def clipboard(**props) = build_widget(:clipboard, **props)
88
- def floating_action_button(**props) = build_widget(:floatingactionbutton, **props)
89
- def floatingactionbutton(**props) = floating_action_button(**props)
90
- def tabs(**props, &block) = build_widget(:tabs, **props, &block)
91
- def tab(**props, &block) = build_widget(:tab, **props, &block)
92
- def tab_bar(**props, &block) = build_widget(:tabbar, **props, &block)
93
- def tabbar(**props, &block) = tab_bar(**props, &block)
94
- def tab_bar_view(**props, &block) = build_widget(:tabbarview, **props, &block)
95
- def tabbarview(**props, &block) = tab_bar_view(**props, &block)
96
- def navigation_bar(**props, &block) = build_widget(:navigationbar, **props, &block)
97
- def navigationbar(**props, &block) = navigation_bar(**props, &block)
98
- def navigation_bar_destination(**props, &block) = build_widget(:navigationbardestination, **props, &block)
99
- def navigationbardestination(**props, &block) = navigation_bar_destination(**props, &block)
100
-
101
- def fab(content = nil, **props)
102
- mapped = props.dup
103
- mapped[:content] = content unless content.nil?
104
- build_widget(:floatingactionbutton, **mapped)
105
- end
106
-
107
- private
108
-
109
- def normalize_image_source(value)
110
- return value unless value.is_a?(Array)
111
- return value.pack("C*") if value.all? { |v| v.is_a?(Integer) }
112
- value
113
- end
114
-
115
- # Flet container alignment expects a vector-like object ({x:, y:}),
116
- # not a plain string. Keep common shorthand compatible.
117
- def normalize_container_props(props)
118
- mapped = props.dup
119
- alignment = mapped[:alignment] || mapped["alignment"]
120
- if alignment == "center" || alignment == :center
121
- mapped[:alignment] = { x: 0, y: 0 }
122
- mapped.delete("alignment")
123
- end
124
- mapped
125
- end
126
- end
127
- end
128
- end
@@ -1,154 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ruflet
4
- module UI
5
- module MaterialControlRegistry
6
- TYPE_MAP = {
7
- "text" => "Text",
8
- "column" => "Column",
9
- "row" => "Row",
10
- "stack" => "Stack",
11
- "gridview" => "GridView",
12
- "grid_view" => "GridView",
13
- "view" => "View",
14
- "container" => "Container",
15
- "checkbox" => "Checkbox",
16
- "radio" => "Radio",
17
- "radiogroup" => "RadioGroup",
18
- "radio_group" => "RadioGroup",
19
- "alertdialog" => "AlertDialog",
20
- "alert_dialog" => "AlertDialog",
21
- "snackbar" => "SnackBar",
22
- "snack_bar" => "SnackBar",
23
- "bottomsheet" => "BottomSheet",
24
- "bottom_sheet" => "BottomSheet",
25
- "markdown" => "Markdown",
26
- "textbutton" => "TextButton",
27
- "text_button" => "TextButton",
28
- "filledbutton" => "FilledButton",
29
- "filled_button" => "FilledButton",
30
- "gesturedetector" => "GestureDetector",
31
- "gesture_detector" => "GestureDetector",
32
- "draggable" => "Draggable",
33
- "dragtarget" => "DragTarget",
34
- "drag_target" => "DragTarget",
35
- "textfield" => "TextField",
36
- "text_field" => "TextField",
37
- "button" => "Button",
38
- "elevatedbutton" => "Button",
39
- "elevated_button" => "Button",
40
- "iconbutton" => "IconButton",
41
- "icon_button" => "IconButton",
42
- "icon" => "Icon",
43
- "image" => "Image",
44
- "appbar" => "AppBar",
45
- "app_bar" => "AppBar",
46
- "floatingactionbutton" => "FloatingActionButton",
47
- "floating_action_button" => "FloatingActionButton",
48
- "tabs" => "Tabs",
49
- "tab" => "Tab",
50
- "tabbar" => "TabBar",
51
- "tab_bar" => "TabBar",
52
- "tabbarview" => "TabBarView",
53
- "tab_bar_view" => "TabBarView",
54
- "navigationbar" => "NavigationBar",
55
- "navigation_bar" => "NavigationBar",
56
- "navigationbardestination" => "NavigationBarDestination",
57
- "navigation_bar_destination" => "NavigationBarDestination",
58
- "switch" => "Switch",
59
- "slider" => "Slider",
60
- "dropdown" => "DropdownM2",
61
- "dropdownm2" => "DropdownM2",
62
- "dropdown_m2" => "DropdownM2",
63
- "option" => "Option",
64
- "card" => "Card",
65
- "banner" => "Banner",
66
- "datepicker" => "DatePicker",
67
- "date_picker" => "DatePicker",
68
- "timepicker" => "TimePicker",
69
- "time_picker" => "TimePicker",
70
- "filledtonalbutton" => "FilledTonalButton",
71
- "filled_tonal_button" => "FilledTonalButton",
72
- "outlinedbutton" => "OutlinedButton",
73
- "outlined_button" => "OutlinedButton",
74
- "listtile" => "ListTile",
75
- "list_tile" => "ListTile",
76
- "progressbar" => "ProgressBar",
77
- "progress_bar" => "ProgressBar",
78
- "safearea" => "SafeArea",
79
- "safe_area" => "SafeArea",
80
- "canvas" => "Canvas",
81
- "line" => "Line",
82
- "service_registry" => "ServiceRegistry",
83
- "url_launcher" => "UrlLauncher",
84
- "clipboard" => "Clipboard",
85
- "audio" => "Audio",
86
- "video" => "Video",
87
- "flashlight" => "Flashlight",
88
- "barchart" => "BarChart",
89
- "barchartgroup" => "BarChartGroup",
90
- "barchartrod" => "BarChartRod",
91
- "barchartrodstackitem" => "BarChartRodStackItem",
92
- "linechart" => "LineChart",
93
- "linechartdata" => "LineChartData",
94
- "linechartdatapoint" => "LineChartDataPoint",
95
- "piechart" => "PieChart",
96
- "piechartsection" => "PieChartSection",
97
- "candlestickchart" => "CandlestickChart",
98
- "candlestickchartspot" => "CandlestickChartSpot",
99
- "radarchart" => "RadarChart",
100
- "radarcharttitle" => "RadarChartTitle",
101
- "radardataset" => "RadarDataSet",
102
- "radardatasetentry" => "RadarDataSetEntry",
103
- "scatterchart" => "ScatterChart",
104
- "scatterchartspot" => "ScatterChartSpot",
105
- "chartaxis" => "ChartAxis",
106
- "chartaxislabel" => "ChartAxisLabel"
107
- }.freeze
108
-
109
- EVENT_PROPS = {
110
- on_click: "click",
111
- on_change: "change",
112
- on_action: "action",
113
- on_submit: "submit",
114
- on_dismiss: "dismiss",
115
- on_tap: "tap",
116
- on_double_tap: "double_tap",
117
- on_long_press: "long_press",
118
- on_hover: "hover",
119
- on_pan_start: "pan_start",
120
- on_pan_update: "pan_update",
121
- on_pan_end: "pan_end",
122
- on_scale_start: "scale_start",
123
- on_scale_update: "scale_update",
124
- on_scale_end: "scale_end",
125
- on_vertical_drag_start: "vertical_drag_start",
126
- on_vertical_drag_update: "vertical_drag_update",
127
- on_vertical_drag_end: "vertical_drag_end",
128
- on_horizontal_drag_start: "horizontal_drag_start",
129
- on_horizontal_drag_update: "horizontal_drag_update",
130
- on_horizontal_drag_end: "horizontal_drag_end",
131
- on_tap_down: "tap_down",
132
- on_long_press_start: "long_press_start",
133
- on_right_pan_start: "right_pan_start",
134
- on_event: "event",
135
- on_load: "load",
136
- on_loaded: "loaded",
137
- on_enter_fullscreen: "enter_fullscreen",
138
- on_exit_fullscreen: "exit_fullscreen",
139
- on_duration_change: "duration_change",
140
- on_position_change: "position_change",
141
- on_state_change: "state_change",
142
- on_seek_complete: "seek_complete",
143
- on_complete: "complete",
144
- on_track_change: "track_change",
145
- on_error: "error",
146
- on_accept: "accept",
147
- on_will_accept: "will_accept",
148
- on_accept_with_details: "accept_with_details",
149
- on_move: "move",
150
- on_leave: "leave"
151
- }.freeze
152
- end
153
- end
154
- end