Skip to content
Merged

Dev #19

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,17 @@ Use `page` only for runtime/page operations (`add`, `update`, `go`, `show_dialog
ruflet new <appname>
ruflet run [scriptname|path] [--web|--desktop] [--port PORT]
ruflet update [web|desktop|all] [--check] [--force] [--platform PLATFORM]
ruflet build <apk|ios|aab|web|macos|windows|linux>
ruflet build <apk|ios|aab|web|macos|windows|linux> [--self] [--verbose]
```

For monorepo development (always uses local CLI source), run:

By default `ruflet build ...` looks for Flutter client at `./ruflet_client`.
Set `RUFLET_CLIENT_DIR` to override.

- `ruflet build ... --self` uses the self-contained Flutter entrypoint with `ruby_runtime`.
- `ruflet build ...` without `--self` builds the server-driven client entrypoint.

## Development (Monorepo)

```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/widgets.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class CounterApp < Ruflet::App
text(value: "You clicked:")
counter
end,
floating_action_button: fab("+", on_click: ->(e) {
floating_action_button: fab(Ruflet::MaterialIcons::ADD, on_click: ->(e) {
@count += 1
e.page.update(counter, value: @count.to_s)
})
Expand Down
68 changes: 40 additions & 28 deletions generated/embedded_ruflet_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -2165,12 +2165,11 @@ module Ruflet
value =
if v.is_a?(Symbol)
v.to_s
elsif v.is_a?(Ruflet::IconData)
v.value
else
v
end
value = normalize_icon_prop(mapped_key, value)
value = value.value if value.is_a?(Ruflet::IconData)
value = normalize_color_prop(mapped_key, value)

result[mapped_key] = value
Expand All @@ -2194,25 +2193,17 @@ module Ruflet

def normalize_icon_prop(key, value)
return value unless icon_prop_key?(key)
codepoint = resolve_icon_codepoint(value)
codepoint.nil? ? value : codepoint
return value if value.nil?
return value if value.is_a?(Integer)
return value if value.is_a?(Ruflet::IconData)

raise ArgumentError, "#{type} #{key} must use Ruflet::MaterialIcons (or another Ruflet::IconData), not #{value.inspect}"
end

def icon_prop_key?(key)
key == "icon" || key.end_with?("_icon")
end

def resolve_icon_codepoint(value)
return nil unless value.is_a?(Integer) || value.is_a?(Symbol) || value.is_a?(String)

codepoint = Ruflet::MaterialIconLookup.codepoint_for(value)
if codepoint.nil? || (value.is_a?(Integer) && codepoint == value)
cupertino = Ruflet::CupertinoIconLookup.codepoint_for(value)
codepoint = cupertino unless cupertino.nil?
end
codepoint
end

def normalized_event_name(event_name)
event_name.to_s.sub(/\Aon_/, "")
end
Expand Down Expand Up @@ -18569,13 +18560,39 @@ module Ruflet
def webview(**props) = web_view(**props)

def fab(content = nil, **props)
mapped = props.dup
mapped[:content] = content unless content.nil?
mapped = normalize_fab_props(props.dup, content)
build_widget(:floatingactionbutton, **mapped)
end

private

def normalize_fab_props(props, content)
mapped = props.dup

explicit_icon = mapped[:icon] || mapped["icon"]
if explicit_icon.is_a?(Ruflet::Control) && content.nil?
mapped.delete(:icon)
mapped.delete("icon")
content = explicit_icon
elsif !explicit_icon.nil? && !explicit_icon.is_a?(Ruflet::IconData)
raise ArgumentError, "fab icon must use Ruflet::MaterialIcons (or another Ruflet::IconData) or an icon(...) control"
end

unless content.nil?
mapped[:content] =
case content
when Ruflet::Control
content
when Ruflet::IconData
icon(icon: content)
else
raise ArgumentError, "fab content must be an icon(...) control or Ruflet::MaterialIcons value"
end
end

mapped
end

def normalize_image_source(value)
return value unless value.is_a?(Array)
return value.pack("C*") if value.all? { |v| v.is_a?(Integer) }
Expand Down Expand Up @@ -20459,9 +20476,12 @@ module Ruflet
end

def normalize_value(key, value)
if icon_prop_key?(key) && (value.is_a?(String) || value.is_a?(Symbol) || value.is_a?(Integer))
codepoint = resolve_icon_codepoint(value)
return codepoint unless codepoint.nil?
if icon_prop_key?(key)
return value if value.is_a?(Integer)
return value.value if value.is_a?(Ruflet::IconData)
return value if value.nil?

raise ArgumentError, "page #{key} must use Ruflet::MaterialIcons (or another Ruflet::IconData), not #{value.inspect}"
end

return value.value if value.is_a?(Ruflet::IconData)
Expand Down Expand Up @@ -20613,14 +20633,6 @@ module Ruflet
end
end

def resolve_icon_codepoint(value)
codepoint = Ruflet::MaterialIconLookup.codepoint_for(value)
if codepoint.nil? || codepoint == value
codepoint = Ruflet::CupertinoIconLookup.codepoint_for(value)
end
codepoint
end

def ensure_clipboard_service
clipboard = services.find { |service| service.is_a?(Control) && service.type == "clipboard" }
return [clipboard, false] if clipboard
Expand Down
68 changes: 40 additions & 28 deletions generated/embedded_ruflet_runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2162,12 +2162,11 @@ def normalize_props(hash)
value =
if v.is_a?(Symbol)
v.to_s
elsif v.is_a?(Ruflet::IconData)
v.value
else
v
end
value = normalize_icon_prop(mapped_key, value)
value = value.value if value.is_a?(Ruflet::IconData)
value = normalize_color_prop(mapped_key, value)

result[mapped_key] = value
Expand All @@ -2191,25 +2190,17 @@ def color_prop_key?(key)

def normalize_icon_prop(key, value)
return value unless icon_prop_key?(key)
codepoint = resolve_icon_codepoint(value)
codepoint.nil? ? value : codepoint
return value if value.nil?
return value if value.is_a?(Integer)
return value if value.is_a?(Ruflet::IconData)

raise ArgumentError, "#{type} #{key} must use Ruflet::MaterialIcons (or another Ruflet::IconData), not #{value.inspect}"
end

def icon_prop_key?(key)
key == "icon" || key.end_with?("_icon")
end

def resolve_icon_codepoint(value)
return nil unless value.is_a?(Integer) || value.is_a?(Symbol) || value.is_a?(String)

codepoint = Ruflet::MaterialIconLookup.codepoint_for(value)
if codepoint.nil? || (value.is_a?(Integer) && codepoint == value)
cupertino = Ruflet::CupertinoIconLookup.codepoint_for(value)
codepoint = cupertino unless cupertino.nil?
end
codepoint
end

def normalized_event_name(event_name)
event_name.to_s.sub(/\Aon_/, "")
end
Expand Down Expand Up @@ -18566,13 +18557,39 @@ def web_view(**props) = build_widget(:webview, **props)
def webview(**props) = web_view(**props)

def fab(content = nil, **props)
mapped = props.dup
mapped[:content] = content unless content.nil?
mapped = normalize_fab_props(props.dup, content)
build_widget(:floatingactionbutton, **mapped)
end

private

def normalize_fab_props(props, content)
mapped = props.dup

explicit_icon = mapped[:icon] || mapped["icon"]
if explicit_icon.is_a?(Ruflet::Control) && content.nil?
mapped.delete(:icon)
mapped.delete("icon")
content = explicit_icon
elsif !explicit_icon.nil? && !explicit_icon.is_a?(Ruflet::IconData)
raise ArgumentError, "fab icon must use Ruflet::MaterialIcons (or another Ruflet::IconData) or an icon(...) control"
end

unless content.nil?
mapped[:content] =
case content
when Ruflet::Control
content
when Ruflet::IconData
icon(icon: content)
else
raise ArgumentError, "fab content must be an icon(...) control or Ruflet::MaterialIcons value"
end
end

mapped
end

def normalize_image_source(value)
return value unless value.is_a?(Array)
return value.pack("C*") if value.all? { |v| v.is_a?(Integer) }
Expand Down Expand Up @@ -20456,9 +20473,12 @@ def normalize_props(hash)
end

def normalize_value(key, value)
if icon_prop_key?(key) && (value.is_a?(String) || value.is_a?(Symbol) || value.is_a?(Integer))
codepoint = resolve_icon_codepoint(value)
return codepoint unless codepoint.nil?
if icon_prop_key?(key)
return value if value.is_a?(Integer)
return value.value if value.is_a?(Ruflet::IconData)
return value if value.nil?

raise ArgumentError, "page #{key} must use Ruflet::MaterialIcons (or another Ruflet::IconData), not #{value.inspect}"
end

return value.value if value.is_a?(Ruflet::IconData)
Expand Down Expand Up @@ -20610,14 +20630,6 @@ def build_page_patch_ops
end
end

def resolve_icon_codepoint(value)
codepoint = Ruflet::MaterialIconLookup.codepoint_for(value)
if codepoint.nil? || codepoint == value
codepoint = Ruflet::CupertinoIconLookup.codepoint_for(value)
end
codepoint
end

def ensure_clipboard_service
clipboard = services.find { |service| service.is_a?(Control) && service.type == "clipboard" }
return [clipboard, false] if clipboard
Expand Down
5 changes: 4 additions & 1 deletion packages/ruflet/lib/ruflet/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def run(argv = ARGV)
command_debug(argv)
when "build"
command_build(argv)
when "install"
command_install(argv)
when "devices"
command_devices(argv)
when "emulators"
Expand Down Expand Up @@ -66,7 +68,8 @@ def print_help
ruflet run [scriptname|path] [--web|--desktop] [--port PORT]
ruflet update [web|desktop|all] [--check] [--force] [--platform PLATFORM]
ruflet debug [scriptname|path]
ruflet build <apk|android|ios|aab|web|macos|windows|linux>
ruflet build <apk|android|ios|aab|web|macos|windows|linux> [--self] [--verbose]
ruflet install [--device DEVICE_ID] [--verbose]
ruflet devices
ruflet emulators
ruflet doctor
Expand Down
Loading
Loading