ruflet 0.0.1
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 +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 +20 -0
- data/lib/ruflet_ui/ruflet/colors.rb +200 -0
- data/lib/ruflet_ui/ruflet/control.rb +154 -0
- data/lib/ruflet_ui/ruflet/dsl.rb +182 -0
- data/lib/ruflet_ui/ruflet/event.rb +28 -0
- data/lib/ruflet_ui/ruflet/icon_data.rb +57 -0
- data/lib/ruflet_ui/ruflet/icons/cupertino/cupertino_icons.rb +54 -0
- data/lib/ruflet_ui/ruflet/icons/cupertino_icon_lookup.rb +112 -0
- data/lib/ruflet_ui/ruflet/icons/material_icon_lookup.rb +112 -0
- data/lib/ruflet_ui/ruflet/icons/material_icons.rb +55 -0
- data/lib/ruflet_ui/ruflet/page.rb +550 -0
- data/lib/ruflet_ui/ruflet/ui/control_factory.rb +22 -0
- data/lib/ruflet_ui/ruflet/ui/control_methods.rb +16 -0
- data/lib/ruflet_ui/ruflet/ui/control_registry.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_action_sheet_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_alert_dialog_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_button_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_dialog_action_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_filled_button_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_navigation_bar_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_slider_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_switch_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/cupertino/cupertino_text_field_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/alert_dialog_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/app_bar_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/bottom_sheet_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/button_control.rb +24 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/checkbox_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/column_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/container_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/drag_target_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/draggable_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/elevated_button_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/filled_button_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/floating_action_button_control.rb +28 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/gesture_detector_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/icon_button_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/icon_control.rb +24 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/image_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/markdown_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/navigation_bar_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/navigation_bar_destination_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/radio_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/radio_group_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/row_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/snack_bar_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/stack_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/tab_bar_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/tab_bar_view_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/tab_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/tabs_control.rb +63 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/text_button_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/text_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/text_field_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/controls/material/view_control.rb +13 -0
- data/lib/ruflet_ui/ruflet/ui/cupertino_control_factory.rb +40 -0
- data/lib/ruflet_ui/ruflet/ui/cupertino_control_methods.rb +26 -0
- data/lib/ruflet_ui/ruflet/ui/cupertino_control_registry.rb +35 -0
- data/lib/ruflet_ui/ruflet/ui/material_control_factory.rb +94 -0
- data/lib/ruflet_ui/ruflet/ui/material_control_methods.rb +116 -0
- data/lib/ruflet_ui/ruflet/ui/material_control_registry.rb +88 -0
- data/lib/ruflet_ui/ruflet/ui/shared_control_forwarders.rb +85 -0
- data/lib/ruflet_ui/ruflet/ui/widget_builder.rb +48 -0
- data/lib/ruflet_ui.rb +112 -0
- metadata +109 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ruflet
|
|
4
|
+
module UI
|
|
5
|
+
module Controls
|
|
6
|
+
class ButtonControl < Ruflet::Control
|
|
7
|
+
def initialize(id: nil, type: "button", **props)
|
|
8
|
+
super(type: type, id: id, **props)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def preprocess_props(props)
|
|
14
|
+
mapped = props.dup
|
|
15
|
+
if mapped.key?(:text) || mapped.key?("text")
|
|
16
|
+
value = mapped.delete(:text) || mapped.delete("text")
|
|
17
|
+
mapped[:content] = value unless mapped.key?(:content) || mapped.key?("content")
|
|
18
|
+
end
|
|
19
|
+
mapped
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ruflet
|
|
4
|
+
module UI
|
|
5
|
+
module Controls
|
|
6
|
+
class FloatingActionButtonControl < Ruflet::Control
|
|
7
|
+
def initialize(id: nil, **props)
|
|
8
|
+
super(type: "floatingactionbutton", id: id, **props)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def preprocess_props(props)
|
|
14
|
+
normalized = props.dup
|
|
15
|
+
|
|
16
|
+
# Accept both correct and common-misspelled foreground color keys.
|
|
17
|
+
if !normalized.key?(:color) && !normalized.key?("color")
|
|
18
|
+
fg = normalized.delete(:foreground_color) || normalized.delete("foreground_color")
|
|
19
|
+
fg ||= normalized.delete(:forground_color) || normalized.delete("forground_color")
|
|
20
|
+
normalized[:color] = fg if fg
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
normalized
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ruflet
|
|
4
|
+
module UI
|
|
5
|
+
module Controls
|
|
6
|
+
class IconControl < Ruflet::Control
|
|
7
|
+
def initialize(id: nil, **props)
|
|
8
|
+
super(type: "icon", id: id, **props)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def preprocess_props(props)
|
|
14
|
+
mapped = props.dup
|
|
15
|
+
if mapped.key?(:name) || mapped.key?("name")
|
|
16
|
+
value = mapped.delete(:name) || mapped.delete("name")
|
|
17
|
+
mapped[:icon] = value unless mapped.key?(:icon) || mapped.key?("icon")
|
|
18
|
+
end
|
|
19
|
+
mapped
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ruflet
|
|
4
|
+
module UI
|
|
5
|
+
module Controls
|
|
6
|
+
class NavigationBarDestinationControl < Ruflet::Control
|
|
7
|
+
def initialize(id: nil, **props)
|
|
8
|
+
super(type: "navigationbardestination", id: id, **props)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|