Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI layout throws exception on Android but not iOS #68

Open
amirrajan opened this issue Apr 28, 2017 · 1 comment
Open

UI layout throws exception on Android but not iOS #68

amirrajan opened this issue Apr 28, 2017 · 1 comment

Comments

@amirrajan
Copy link
Collaborator

border = UI::View.new

{
  background_color: :black,
  width: 50,
  height: 50,
  align_self: :center
}.each do |k, v|
    border.send("#{k}=", v)
  end
end

view.add_child border
view.update_layout

This however works:

border = UI::View.new

{
  background_color: :black,
  width: 50,
  height: 50,
  align_self: :center
}.each do |k, v|
    if v == :center
      border.send("#{k}=", :center)
    else
      border.send("#{k}=", v)
    end
  end
end

view.add_child border
view.update_layout

The following properties would be impacted because of this (I think):

  • direction, "inherit", "ltr", "rtl"
  • flex_direction, "column", "column_reverse", "row", "row_reverse"
  • justify_content, "flex_start", "center", "flex_end", "space_between", "space_around"
  • align_content, "auto", "flex_start", "center", "flex_end", "stretch"
  • align_items, "auto", "flex_start", "center", "flex_end", "stretch"
  • align_self, "auto", "flex_start", "center", "flex_end", "stretch"
  • position_type, "relative", "absolute"
  • flex_wrap, "no_wrap", "wrap"
@jjaffeux
Copy link
Contributor

jjaffeux commented Apr 29, 2017

I think there's probably a bug in:

#define define_property_sym(name, count) \
    static VALUE node_##name##s[count] = { Qnil } ; \
    static VALUE \
    node_##name##_get(VALUE rcv, SEL sel) \
    { \
        int value = NODE(rcv)->node->style.name; \
	if (value >= count) { \
	    rb_raise(rb_eArgError, "incorrect value for %s", #name); \
	} \
        return node_##name##s[value]; \
    } \
    static VALUE \
    node_##name##_set(VALUE rcv, SEL sel, VALUE value) \
    { \
	struct ruby_css_node *node = NODE(rcv); \
        for (int i = 0; i < count; i++) { \
	    if (node_##name##s[i] == value) { \
		(*(int *)&node->node->style.name) = i; \
		return value; \
	    } \
	} \
	rb_raise(rb_eArgError, "incorrect value for %s", #name); \
    }

more exactly:

    static VALUE \
    node_##name##_set(VALUE rcv, SEL sel, VALUE value) \
    { \
	struct ruby_css_node *node = NODE(rcv); \
        for (int i = 0; i < count; i++) { \
	    if (node_##name##s[i] == value) { \
		(*(int *)&node->node->style.name) = i; \
		return value; \
	    } \
	} \
	rb_raise(rb_eArgError, "incorrect value for %s", #name); \
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants