-
Notifications
You must be signed in to change notification settings - Fork 148
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
how to style table cell data #740
Comments
Are you using RedPotion, @gjlloyd ? |
no, just straight ProMotion, although not opposed if RedPotion is the way to go. |
@gjlloyd easier to accomplish using redpotion for sure, because you can rely on RMQ's styling. Then its as simple as creating a custom cell with the labels you need on it, and provide proper styles for them - etc. |
Yeah, ProMotion doesn't really provide a view layer, which RedPotion does (with RMQ). I'd recommend you go that route, if you're willing! |
I'm actually trying to do exactly this (with RedPotion), and have a stylesheet and custom class set up, but the styles aren't being applied as I would have expected, any insights on what I'm doing wrong? See the link for the relevant classes. For what it's worth the styles are correctly applied if I run |
so I'm guessing that before the restyle things aren't far enough to the right on larger devices This is a common issue that comes up, def rmq_build
content.append!(UILabel, :followup_prompt_cell_label)
apply_style :followup_prompt_cell
end def rmq_build
rmq(self).layout(w: screen_width)
content
.apply_style(:followup_prompt_cell)
.append!(UILabel, :followup_prompt_cell_label)
end this then makes the cell be the width of the screen even before rendering. Then when you use Hopefully that helps or puts you in the right direction |
Sorry, I should have clarified, none of the frame styles are being applied, even with the updated function. (FYI |
oh, yeah sorry, I thought I was in a stylesheet context there... its do you have a repo I could clone, or a screenshot showing the layout before resytle? |
(main)> rmq.find(FollowupPromptCell).first.frame.log
*****************---*******---**************************
* | | * window
* 0 top | * {w: 375, h: 667}
* | | *
* --- | * superview
* ***************|***** --- * {w: 375, h: 603}
* * | * | *
* * | * | *
* * 44 bottom * | * view
* 0 * | * | * {l: 0, t: 0,
*|-- left --|* | * | * w: 375, h: 44}
* * | * height 44 *
* * | * | * z_order: 0
* * 375 | * | * z_position: 0.0
*|------------------ right -+---|* | *
* * | * | 0 * Location in root view
* * | * |--+--from_right---|* {l: 0, t: 0,
* * --- * | * w: 375, h: 44}
* ***************---*** --- *
* | *
* |------ width - + --| *
* 375 | *
* | *
* | *
* 559 from_bottom *
* | *
* --- *
******************************************************** |
so I can see the cell is 375 wide, and 44 high - which means the width got set properly, and I would bet the 44 is the default height - you need to either set Looking at the gist more, i see that you are definining then you have this is going to make a view that is so I think the problem is, you either want a smaller area for your labels (not so wide) or you want to align the text right on one of them - but run the risk over overlap for example you could do something like def left_text(st)
st.frame = { w: :half, t: 16, l: 16, h: 20 }
end
def right_text(st)
st.frame = { w: :half, t: 16, fr: 16, h: 20 }
st.text_alignment = :right
end |
I've run into a similar issue (NOTE: Fix/workaround below). It appears both the custom Relevant code: module BarCellStylesheet
def bar_cell_height
140
end
def bar_cell_title(st)
st.frame = {l: 10, fr: 10, t: 10, fb: 10}
st.font = font.medium
st.color = color.black
st.background_color = color.blue
end
end
class FooScreen < PM::TableScreen
title "Your title here"
stylesheet FooScreenStylesheet
refreshable callback: :on_refresh,
pull_message: 'Pull to refresh',
refreshing: 'Refreshing data…',
updated_format: "Last updated at %s",
updated_time_format: "%l:%M %p"
def on_refresh
end_refreshing
update_table_data
reapply_styles
end
def on_load
update_table_data
reapply_styles
end
def table_data
[
{
title: "Section",
cells: [
{ cell_class: BarCell, height: stylesheet.bar_cell_height, title: "Foo"},
{ cell_class: BarCell, height: stylesheet.bar_cell_height, title: "Bar"}
]
}
]
end
end
class BarCell < PM::TableViewCell
def on_load
# NOTE: This line is the fix.
rmq(self, self.contentView).layout(h: stylesheet.bar_cell_height, w: stylesheet.screen_width)
apply_style :bar_cell
content = find(self.contentView)
@title = content.append! UILabel, :bar_cell_title
end
def title=(value)
@title.text = value
end
def title
@title
end
end My workaround is included in the snippet above (using |
Yeah, that makes a lot of sense, @jcarbo . I'd say it would be a RedPotion fix, since we generally put RMQ/ProMotion glue code in there. Want to look into submitting a patch to RP? |
can someone point me to an example of putting several pieces of data on one table cell?
i'm trying to do something like this:
product 1------------$99.00
product 2------------$48.00
etc.. with one string left aligned, one right aligned (ignore dashes in center).. i have looked at lots of examples would appreciate the help.
The text was updated successfully, but these errors were encountered: